void (@NotNull Collection<DataNode<BuildScriptClasspathData>> buildClasspathNodes, @NotNull Map<String, DataNode<? extends ModuleData>> buildSrcModules, @NotNull DataNode<? extends ModuleData> buildSrcModuleNode) { Set<String> buildSrcRuntimeSourcesPaths = new HashSet<>(); Set<String> buildSrcRuntimeClassesPaths = new HashSet<>(); addSourcePaths(buildSrcRuntimeSourcesPaths, buildSrcModuleNode); for (DataNode<?> child : buildSrcModuleNode.getChildren()) { Object childData = child.getData(); if (childData instanceof ModuleDependencyData moduleDependencyData && moduleDependencyData.getScope().isForProductionRuntime()) { DataNode<? extends ModuleData> depModuleNode = buildSrcModules.get(moduleDependencyData.getTarget().getId()); if (depModuleNode != null) { addSourcePaths(buildSrcRuntimeSourcesPaths, depModuleNode); } } else if (childData instanceof LibraryDependencyData dependencyData) { // exclude generated gradle-api jar the gradle api classes/sources handled separately by BuildClasspathModuleGradleDataService if (dependencyData.getExternalName().startsWith("gradle-api-")) { continue; } LibraryData libraryData = dependencyData.getTarget(); buildSrcRuntimeSourcesPaths.addAll(libraryData.getPaths(LibraryPathType.SOURCE)); buildSrcRuntimeClassesPaths.addAll(libraryData.getPaths(LibraryPathType.BINARY)); } } if (!buildSrcRuntimeSourcesPaths.isEmpty() || !buildSrcRuntimeClassesPaths.isEmpty()) { buildClasspathNodes.forEach(classpathNode -> { BuildScriptClasspathData copyFrom = classpathNode.getData(); List<BuildScriptClasspathData.ClasspathEntry> classpathEntries = new ArrayList<>(copyFrom.getClasspathEntries().size() + 1); classpathEntries.addAll(copyFrom.getClasspathEntries()); classpathEntries.add(BuildScriptClasspathData.ClasspathEntry.create( new HashSet<>(buildSrcRuntimeClassesPaths), new HashSet<>(buildSrcRuntimeSourcesPaths), Collections.emptySet() )); BuildScriptClasspathData buildScriptClasspathData = new BuildScriptClasspathData(GradleConstants.SYSTEM_ID, classpathEntries); buildScriptClasspathData.setGradleHomeDir(copyFrom.getGradleHomeDir()); DataNode<?> parent = classpathNode.getParent(); assert parent != null; parent.createChild(BuildScriptClasspathData.KEY, buildScriptClasspathData); classpathNode.clear(true); }); } }