diff --git a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildRunner.java b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildRunner.java index 51a43222ae6e..f2650717ff50 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildRunner.java +++ b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildRunner.java @@ -119,13 +119,14 @@ public class BuildRunner { public void runBuild(ProjectDescriptor pd, CanceledStatus cs, @Nullable Callbacks.ConstantAffectionResolver constantSearch, MessageHandler msgHandler, BuildType buildType) throws Exception { for (int attempt = 0; attempt < 2; attempt++) { - final CompileScope compileScope = createCompilationScope(pd, myScopes, myFilePaths); + final boolean forceClean = myForceCleanCaches && myFilePaths.isEmpty(); + final CompileScope compileScope = createCompilationScope(pd, myScopes, myFilePaths, forceClean); final IncProjectBuilder builder = new IncProjectBuilder(pd, BuilderRegistry.getInstance(), myBuilderParams, cs, constantSearch); builder.addMessageHandler(msgHandler); try { switch (buildType) { case BUILD: - builder.build(compileScope, myForceCleanCaches); + builder.build(compileScope, forceClean); break; case CLEAN: @@ -150,8 +151,8 @@ public class BuildRunner { } } - private CompileScope createCompilationScope(ProjectDescriptor pd, List scopes, - Collection paths) throws Exception { + private static CompileScope createCompilationScope(ProjectDescriptor pd, List scopes, + Collection paths, final boolean forceClean) throws Exception { Set> targetTypes = new HashSet>(); Set> targetTypesToForceBuild = new HashSet>(); Set> targets = new HashSet>(); @@ -164,7 +165,7 @@ public class BuildRunner { LOG.info("Unknown target type: " + scope.getTypeId()); continue; } - if (scope.getForceBuild() || myForceCleanCaches && paths.isEmpty()) { + if (scope.getForceBuild() || forceClean) { targetTypesToForceBuild.add(targetType); } if (scope.getAllTargets()) {