From 5c6632e14c460acc2d08b3c17f5c53762953b83e Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 26 Nov 2009 17:15:19 +0300 Subject: [PATCH] IDEADEV-41556: Artifacts: if artifact has 'build on make' option off, don't rebuild it on project make --- .../compiler/IncrementalArtifactsCompiler.java | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalArtifactsCompiler.java b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalArtifactsCompiler.java index e3f531cba8..43d967f299 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalArtifactsCompiler.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalArtifactsCompiler.java @@ -37,6 +37,7 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; @@ -413,7 +414,7 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler { final List filesToDelete = context.getUserData(FILES_TO_DELETE_KEY); final Set deletedJars; if (filesToDelete != null) { - deletedJars = deleteFiles(context.getProject(), filesToDelete); + deletedJars = deleteFiles(filesToDelete, context); } else { deletedJars = Collections.emptySet(); @@ -422,14 +423,34 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler { return deletedJars; } - protected Set deleteFiles(final Project project, final List paths) { + private Set deleteFiles(final List paths, CompileContext context) { + + final Set artifactsToBuild = getAffectedArtifacts(context); + final boolean testMode = ApplicationManager.getApplication().isUnitTestMode(); final THashSet deletedJars = new THashSet(); if (LOG.isDebugEnabled()) { LOG.debug("Deleting outdated files..."); } + + final Artifact[] allArtifacts = ArtifactManager.getInstance(context.getProject()).getArtifacts(); + List filesToRefresh = new ArrayList(); for (String fullPath : paths) { + boolean isUnderOutput = false; + boolean isInArtifactsToBuild = false; + for (Artifact artifact : allArtifacts) { + final String path = artifact.getOutputPath(); + if (!StringUtil.isEmpty(path) && FileUtil.startsWith(fullPath, path)) { + isUnderOutput = true; + if (artifactsToBuild.contains(artifact)) { + isInArtifactsToBuild = true; + break; + } + } + } + if (isUnderOutput && !isInArtifactsToBuild) continue; + int end = fullPath.indexOf(JarFileSystem.JAR_SEPARATOR); String filePath = end != -1 ? fullPath.substring(0, end) : fullPath; if (end != -1) { @@ -446,7 +467,7 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler { if (testMode) { CompilerManagerImpl.addDeletedPath(file.getAbsolutePath()); } - getOutputItemsCache(project).remove(fullPath); + getOutputItemsCache(context.getProject()).remove(fullPath); } } -- 2.11.4.GIT