2 * Copyright 2000-2010 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.packaging.impl.compiler;
18 import com.intellij.compiler.impl.newApi.CompileItem;
19 import com.intellij.compiler.impl.newApi.CompilerInstance;
20 import com.intellij.compiler.impl.newApi.NewCompiler;
21 import com.intellij.compiler.impl.newApi.VirtualFileCompileItem;
22 import com.intellij.openapi.compiler.CompileContext;
23 import com.intellij.openapi.compiler.CompileScope;
24 import com.intellij.openapi.compiler.CompilerManager;
25 import com.intellij.openapi.project.Project;
26 import com.intellij.openapi.util.Key;
27 import com.intellij.packaging.artifacts.Artifact;
28 import com.intellij.util.io.DataExternalizer;
29 import com.intellij.util.io.KeyDescriptor;
30 import org.jetbrains.annotations.NotNull;
31 import org.jetbrains.annotations.Nullable;
38 public class ArtifactsCompiler extends NewCompiler<String, ArtifactPackagingItemOutputState> {
39 static final Key<Set<String>> WRITTEN_PATHS_KEY = Key.create("artifacts_written_paths");
40 static final Key<Set<Artifact>> AFFECTED_ARTIFACTS = Key.create("affected_artifacts");
42 public ArtifactsCompiler() {
43 super("artifacts_compiler", 0, NewCompiler.CompileOrderPlace.PACKAGING);
47 public static ArtifactsCompiler getInstance(@NotNull Project project) {
48 final ArtifactsCompiler[] compilers = CompilerManager.getInstance(project).getCompilers(ArtifactsCompiler.class);
49 return compilers.length == 1 ? compilers[0] : null;
54 public KeyDescriptor<String> getItemKeyDescriptor() {
55 return VirtualFileCompileItem.KEY_DESCRIPTOR;
60 public DataExternalizer<ArtifactPackagingItemOutputState> getItemStateExternalizer() {
61 return ArtifactCompilerCompileItem.OUTPUT_EXTERNALIZER;
66 public CompilerInstance<ArtifactBuildTarget, ? extends CompileItem<String, ArtifactPackagingItemOutputState>, String, ArtifactPackagingItemOutputState> createInstance(
67 @NotNull CompileContext context) {
68 return new ArtifactsCompilerInstance(context);
71 public boolean validateConfiguration(final CompileScope scope) {
76 public String getDescription() {
77 return "Artifacts Packaging Compiler";
80 public static Set<Artifact> getAffectedArtifacts(final CompileContext compileContext) {
81 return compileContext.getUserData(AFFECTED_ARTIFACTS);
85 public static Set<String> getWrittenPaths(@NotNull CompileContext context) {
86 return context.getUserData(WRITTEN_PATHS_KEY);