void (@NotNull DataNode<ProjectData> resultProjectDataNode, @Nullable String buildName, @NotNull Collection<DataNode<BuildScriptClasspathData>> buildClasspathNodes, @NotNull Map<String, DataNode<ModuleData>> includedModulesPaths, @NotNull DefaultProjectResolverContext buildSrcResolverCtx, @NotNull Function<ProjectConnection, DataNode<ProjectData>> projectConnectionDataNodeFunction) { final String projectPath = buildSrcResolverCtx.getProjectPath(); File projectPathFile = new File(projectPath); if (!projectPathFile.isDirectory()) { return; } if (includedModulesPaths.containsKey(projectPath)) { // `buildSrc` has been already included into the main build (prohibited since 6.0, https://docs.gradle.org/current/userguide/upgrading_version_5.html#buildsrc_is_now_reserved_as_a_project_and_subproject_build_name) return; } if (ArrayUtil.isEmpty(projectPathFile.list((dir, name) -> !name.equals(".gradle") && !name.equals("build")))) { return; } if (buildSrcResolverCtx.isPreviewMode()) { ModuleData buildSrcModuleData = new ModuleData(":buildSrc", GradleConstants.SYSTEM_ID, getDefaultModuleTypeId(), BUILD_SRC_NAME, projectPath, projectPath); GradleModuleDataKt.setBuildSrcModule(buildSrcModuleData); resultProjectDataNode.createChild(ProjectKeys.MODULE, buildSrcModuleData); return; } final DataNode<ProjectData> buildSrcProjectDataNode = myProjectResolver.getHelper().execute( projectPath, buildSrcResolverCtx.getSettings(), mySyncTaskId, myListener, null, projectConnectionDataNodeFunction); if (buildSrcProjectDataNode == null) return; for (DataNode<LibraryData> libraryDataNode : getChildren(buildSrcProjectDataNode, ProjectKeys.LIBRARY)) { GradleProjectResolverUtil.linkProjectLibrary(resultProjectDataNode, libraryDataNode.getData()); } Map<String, DataNode<? extends ModuleData>> buildSrcModules = new HashMap<>(); boolean modulePerSourceSet = buildSrcResolverCtx.isResolveModulePerSourceSet(); DataNode<? extends ModuleData> buildSrcModuleNode = null; for (DataNode<ModuleData> moduleNode : getChildren(buildSrcProjectDataNode, ProjectKeys.MODULE)) { final ModuleData moduleData = moduleNode.getData(); buildSrcModules.put(moduleData.getId(), moduleNode); boolean isBuildSrcModule = BUILD_SRC_NAME.equals(moduleData.getExternalName()); if (isBuildSrcModule && !modulePerSourceSet) { buildSrcModuleNode = moduleNode; } if (modulePerSourceSet) { for (DataNode<GradleSourceSetData> sourceSetNode : getChildren(moduleNode, GradleSourceSetData.KEY)) { buildSrcModules.put(sourceSetNode.getData().getId(), sourceSetNode); if (isBuildSrcModule && buildSrcModuleNode == null && sourceSetNode.getData().getExternalName().endsWith(":main")) { buildSrcModuleNode = sourceSetNode; } } } DataNode<ModuleData> includedModule = includedModulesPaths.get(moduleData.getLinkedExternalProjectPath()); if (includedModule == null) { GradleModuleDataKt.setBuildSrcModule(moduleData); resultProjectDataNode.addChild(moduleNode); String[] moduleGroup = getModuleGroup(resultProjectDataNode, buildName, buildSrcResolverCtx, moduleData); if (moduleGroup != null) { moduleData.setIdeModuleGroup(moduleGroup); } for (DataNode<GradleSourceSetData> sourceSetNode : getChildren(moduleNode, GradleSourceSetData.KEY)) { if (moduleGroup != null) { sourceSetNode.getData().setIdeModuleGroup(moduleGroup); } getChildren(sourceSetNode, ProjectKeys.MODULE_DEPENDENCY).forEach( node -> maybeUpdateNonBuildSrcModuleDependencies(includedModulesPaths, node.getData())); } } } if (buildSrcModuleNode != null) { addBuildSrcToBuildScriptClasspathData(buildClasspathNodes, buildSrcModules, buildSrcModuleNode); } }