List<TargetTypeBuildScope> (@NotNull CompileContextImpl compileContext, CompileScope scope, Collection<String> paths) { List<TargetTypeBuildScope> scopes = new ArrayList<>(); final boolean forceBuild = !compileContext.isMake(); List<TargetTypeBuildScope> explicitScopes = CompileScopeUtil.getBaseScopeForExternalBuild(scope); if (explicitScopes != null) { scopes.addAll(explicitScopes); } else if (!compileContext.isRebuild() && (!paths.isEmpty() || !CompileScopeUtil.allProjectModulesAffected(compileContext))) { CompileScopeUtil.addScopesForSourceSets(scope.getAffectedSourceSets(), scope.getAffectedUnloadedModules(), scopes, forceBuild); } else { final Collection<ModuleSourceSet> sourceSets = scope.getAffectedSourceSets(); boolean includeTests = sourceSets.isEmpty(); for (ModuleSourceSet sourceSet : sourceSets) { if (sourceSet.getType().isTest()) { includeTests = true; break; } } if (includeTests) { scopes.addAll(CmdlineProtoUtil.createAllModulesScopes(forceBuild)); } else { scopes.add(CmdlineProtoUtil.createAllModulesProductionScope(forceBuild)); } } if (paths.isEmpty()) { scopes = mergeScopesFromProviders(scope, scopes, forceBuild); } return scopes; }