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.*;
19 import com.intellij.openapi.compiler.CompileContext;
20 import com.intellij.openapi.compiler.CompileScope;
21 import com.intellij.openapi.compiler.CompilerManager;
22 import com.intellij.openapi.project.Project;
23 import com.intellij.openapi.util.Key;
24 import com.intellij.packaging.artifacts.Artifact;
25 import com.intellij.util.io.DataExternalizer;
26 import com.intellij.util.io.KeyDescriptor;
27 import org.jetbrains.annotations.NotNull;
28 import org.jetbrains.annotations.Nullable;
35 public class ArtifactsCompiler extends NewCompiler<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState> {
36 static final Key<Set<String>> WRITTEN_PATHS_KEY = Key.create("artifacts_written_paths");
37 static final Key<Set<Artifact>> AFFECTED_ARTIFACTS = Key.create("affected_artifacts");
39 public ArtifactsCompiler() {
40 super("artifacts_compiler", 0, NewCompiler.CompileOrderPlace.PACKAGING);
44 public static ArtifactsCompiler getInstance(@NotNull Project project) {
45 final ArtifactsCompiler[] compilers = CompilerManager.getInstance(project).getCompilers(ArtifactsCompiler.class);
46 return compilers.length == 1 ? compilers[0] : null;
51 public KeyDescriptor<String> getItemKeyDescriptor() {
52 return VirtualFileCompileItem.KEY_DESCRIPTOR;
57 public DataExternalizer<VirtualFilePersistentState> getSourceStateExternalizer() {
58 return VirtualFileStateExternalizer.INSTANCE;
63 public DataExternalizer<ArtifactPackagingItemOutputState> getOutputStateExternalizer() {
64 return new ArtifactPackagingItemExternalizer();
69 public CompilerInstance<ArtifactBuildTarget, ? extends CompileItem<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>, String, VirtualFilePersistentState, ArtifactPackagingItemOutputState> createInstance(
70 @NotNull CompileContext context) {
71 return new ArtifactsCompilerInstance(context);
74 public boolean validateConfiguration(final CompileScope scope) {
79 public String getDescription() {
80 return "Artifacts Packaging Compiler";
83 public static Set<Artifact> getAffectedArtifacts(final CompileContext compileContext) {
84 return compileContext.getUserData(AFFECTED_ARTIFACTS);
88 public static Set<String> getWrittenPaths(@NotNull CompileContext context) {
89 return context.getUserData(WRITTEN_PATHS_KEY);