DataNode<ModuleData> (@NotNull IdeaModule gradleModule, @NotNull DataNode<ProjectData> projectDataNode) { DataNode<ModuleData> mainModuleNode = createMainModule(resolverCtx, gradleModule, projectDataNode); final ModuleData mainModuleData = mainModuleNode.getData(); final String mainModuleConfigPath = mainModuleData.getLinkedExternalProjectPath(); final String mainModuleFileDirectoryPath = mainModuleData.getModuleFileDirectoryPath(); final String jdkName = getJdkName(gradleModule); String[] moduleGroup = null; if (!resolverCtx.isUseQualifiedModuleNames()) { moduleGroup = getIdeModuleGroup(mainModuleData.getInternalName(), gradleModule); mainModuleData.setIdeModuleGroup(moduleGroup); } if (resolverCtx.isResolveModulePerSourceSet()) { ExternalProject externalProject = getExternalProject(gradleModule, resolverCtx); assert externalProject != null; for (ExternalSourceSet sourceSet : externalProject.getSourceSets().values()) { final String moduleId = getModuleId(resolverCtx, gradleModule, sourceSet); final String moduleExternalName = gradleModule.getName() + ":" + sourceSet.getName(); final String moduleInternalName = getInternalModuleName(gradleModule, externalProject, sourceSet.getName(), resolverCtx); GradleSourceSetData sourceSetData = new GradleSourceSetData( moduleId, moduleExternalName, moduleInternalName, mainModuleFileDirectoryPath, mainModuleConfigPath); sourceSetData.setGroup(externalProject.getGroup()); if ("main".equals(sourceSet.getName())) { sourceSetData.setPublication(new ProjectId(externalProject.getGroup(), externalProject.getName(), externalProject.getVersion())); } sourceSetData.setVersion(externalProject.getVersion()); sourceSetData.setIdeModuleGroup(moduleGroup); sourceSetData.internalSetSourceCompatibility(sourceSet.getSourceCompatibility()); sourceSetData.internalSetTargetCompatibility(sourceSet.getTargetCompatibility()); sourceSetData.internalSetSdkName(jdkName); final Set<File> artifacts = FileCollectionFactory.createCanonicalFileSet(); if ("main".equals(sourceSet.getName())) { final Set<File> defaultArtifacts = externalProject.getArtifactsByConfiguration().get("default"); if (defaultArtifacts != null) { artifacts.addAll(defaultArtifacts); } } else { if ("test".equals(sourceSet.getName())) { sourceSetData.setProductionModuleId(getInternalModuleName(gradleModule, externalProject, "main", resolverCtx)); final Set<File> testsArtifacts = externalProject.getArtifactsByConfiguration().get("tests"); if (testsArtifacts != null) { artifacts.addAll(testsArtifacts); } } } artifacts.addAll(sourceSet.getArtifacts()); for (ExternalSourceDirectorySet directorySet : sourceSet.getSources().values()) { artifacts.addAll(directorySet.getGradleOutputDirs()); } sourceSetData.setArtifacts(new ArrayList<>(artifacts)); DataNode<GradleSourceSetData> sourceSetDataNode = mainModuleNode.createChild(GradleSourceSetData.KEY, sourceSetData); final Map<String, Pair<DataNode<GradleSourceSetData>, ExternalSourceSet>> sourceSetMap = projectDataNode.getUserData(GradleProjectResolver.RESOLVED_SOURCE_SETS); assert sourceSetMap != null; sourceSetMap.put(moduleId, Pair.create(sourceSetDataNode, sourceSet)); } } else { try { IdeaJavaLanguageSettings languageSettings = gradleModule.getJavaLanguageSettings(); if (languageSettings != null) { if (languageSettings.getLanguageLevel() != null) { mainModuleData.internalSetSourceCompatibility(languageSettings.getLanguageLevel().toString()); } if (languageSettings.getTargetBytecodeVersion() != null) { mainModuleData.internalSetTargetCompatibility(languageSettings.getTargetBytecodeVersion().toString()); } } mainModuleData.internalSetSdkName(jdkName); } // todo[Vlad] the catch can be omitted when the support of the Gradle < 3.0 will be dropped catch (UnsupportedMethodException ignore) { // org.gradle.tooling.model.idea.IdeaModule.getJavaLanguageSettings method supported since Gradle 2.11 } } final ProjectData projectData = projectDataNode.getData(); if (StringUtil.equals(mainModuleData.getLinkedExternalProjectPath(), projectData.getLinkedExternalProjectPath())) { projectData.setGroup(mainModuleData.getGroup()); projectData.setVersion(mainModuleData.getVersion()); } populateBuildScriptSource(gradleModule, mainModuleNode); return mainModuleNode; }