Set<Artifact> (final Project project, final CompileScope compileScope, final boolean addIncludedArtifactsWithOutputPathsOnly) { final Artifact[] artifactsFromScope = getArtifacts(compileScope); final ArtifactManager artifactManager = ArtifactManager.getInstance(project); PackagingElementResolvingContext context = artifactManager.getResolvingContext(); if (artifactsFromScope != null) { return addIncludedArtifacts(Arrays.asList(artifactsFromScope), context, addIncludedArtifactsWithOutputPathsOnly); } final Set<Artifact> cached = compileScope.getUserData(CACHED_ARTIFACTS_KEY); if (cached != null) { return cached; } Set<Artifact> artifacts = new HashSet<>(); final Set<Module> modules = Set.of(compileScope.getAffectedModules()); final List<Module> allModules = Arrays.asList(ModuleManager.getInstance(project).getModules()); for (Artifact artifact : artifactManager.getArtifacts()) { if (artifact.isBuildOnMake()) { if (modules.containsAll(allModules) || containsModuleOutput(artifact, modules, context)) { artifacts.add(artifact); } } } Set<Artifact> result = addIncludedArtifacts(artifacts, context, addIncludedArtifactsWithOutputPathsOnly); compileScope.putUserData(CACHED_ARTIFACTS_KEY, result); return result; }