From 0d7566f5969412ec649cf82910b5d9c5f1453976 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 12 Nov 2009 16:23:38 +0300 Subject: [PATCH] IDEADEV-41334: Building an EAR artifacts deploy other artifacts from other EAR files --- .../impl/compiler/ArtifactCompileScope.java | 34 +++++++++++++++------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompileScope.java b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompileScope.java index 882f166e33..53f94d73bd 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompileScope.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompileScope.java @@ -18,6 +18,7 @@ package com.intellij.packaging.impl.compiler; import com.intellij.compiler.impl.ModuleCompileScope; import com.intellij.openapi.compiler.CompileScope; import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.packaging.artifacts.Artifact; @@ -28,9 +29,11 @@ import com.intellij.packaging.impl.elements.ModuleOutputElementType; import com.intellij.packaging.impl.elements.ModuleOutputPackagingElement; import com.intellij.util.Processor; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; /** * @author nik @@ -68,22 +71,33 @@ public class ArtifactCompileScope { return baseScope; } - @Nullable - public static Artifact[] getArtifacts(@NotNull CompileScope compileScope) { - return compileScope.getUserData(ARTIFACTS_KEY); - } - public static Set getArtifactsToBuild(final Project project, final CompileScope compileScope) { - final Artifact[] artifactsFromScope = getArtifacts(compileScope); + final Artifact[] artifactsFromScope = compileScope.getUserData(ARTIFACTS_KEY); if (artifactsFromScope != null) { return new HashSet(Arrays.asList(artifactsFromScope)); } Set artifacts = new HashSet(); - for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) { + final ArtifactManager artifactManager = ArtifactManager.getInstance(project); + final Set modules = new HashSet(Arrays.asList(compileScope.getAffectedModules())); + for (Artifact artifact : artifactManager.getArtifacts()) { if (artifact.isBuildOnMake()) { - artifacts.add(artifact); + if (modules.containsAll(Arrays.asList(ModuleManager.getInstance(project).getModules())) + || containsModuleOutput(artifact, modules, artifactManager)) { + artifacts.add(artifact); + } } } return artifacts; } + + private static boolean containsModuleOutput(Artifact artifact, final Set modules, ArtifactManager artifactManager) { + final PackagingElementResolvingContext context = artifactManager.getResolvingContext(); + return !ArtifactUtil.processPackagingElements(artifact, ModuleOutputElementType.MODULE_OUTPUT_ELEMENT_TYPE, + new Processor() { + public boolean process(ModuleOutputPackagingElement moduleOutputPackagingElement) { + final Module module = moduleOutputPackagingElement.findModule(context); + return module == null || !modules.contains(module); + } + }, context, true); + } } -- 2.11.4.GIT