mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-02 00:57:59 +07:00
IDEA-222149 Duplicate subprojects in Gradle Tool Window
GitOrigin-RevId: a602d90027bfc011519e62faec03aed82c058849
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7562d68b7d
commit
de07c977eb
+25
@@ -14,6 +14,7 @@ import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemModulePropertyManager;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.*;
|
||||
import com.intellij.openapi.externalSystem.service.execution.ExternalSystemJdkProvider;
|
||||
import com.intellij.openapi.externalSystem.service.project.IdeModelsProvider;
|
||||
@@ -164,6 +165,7 @@ public abstract class AbstractModuleDataService<E extends ModuleData> extends Ab
|
||||
if (unloadedModuleDescription == null) {
|
||||
result.add(node);
|
||||
}
|
||||
markExistedModulesWithSameRoot(node, modelsProvider);
|
||||
}
|
||||
else {
|
||||
node.putUserData(MODULE_KEY, module);
|
||||
@@ -172,6 +174,29 @@ public abstract class AbstractModuleDataService<E extends ModuleData> extends Ab
|
||||
return result;
|
||||
}
|
||||
|
||||
private void markExistedModulesWithSameRoot(DataNode<E> node,
|
||||
IdeModifiableModelsProvider modelsProvider) {
|
||||
ModuleData moduleData = node.getData();
|
||||
ProjectSystemId projectSystemId = moduleData.getOwner();
|
||||
Arrays.stream(modelsProvider.getModules())
|
||||
.filter(ideModule -> isModulePointsSameRoot(moduleData, ideModule))
|
||||
.filter(module -> !ExternalSystemApiUtil.isExternalSystemAwareModule(projectSystemId, module))
|
||||
.forEach(module -> {
|
||||
ExternalSystemModulePropertyManager.getInstance(module)
|
||||
.setExternalOptions(projectSystemId, moduleData, node.getData(ProjectKeys.PROJECT));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private static boolean isModulePointsSameRoot(ModuleData moduleData, Module ideModule) {
|
||||
for (VirtualFile root: ModuleRootManager.getInstance(ideModule).getContentRoots()) {
|
||||
if (FileUtil.pathsEqual(root.getPath(), moduleData.getLinkedExternalProjectPath())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void syncPaths(@NotNull Module module, @NotNull ModifiableRootModel modifiableModel, @NotNull ModuleData data) {
|
||||
CompilerModuleExtension extension = modifiableModel.getModuleExtension(CompilerModuleExtension.class);
|
||||
if (extension == null) {
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
View root() {
|
||||
rooot() {
|
||||
Tasks() {
|
||||
build setup() {
|
||||
init()
|
||||
wrapper()
|
||||
}
|
||||
help() {
|
||||
buildEnvironment()
|
||||
components()
|
||||
dependencies()
|
||||
dependencyInsight()
|
||||
dependentComponents()
|
||||
help()
|
||||
model()
|
||||
projects()
|
||||
properties()
|
||||
tasks()
|
||||
}
|
||||
}
|
||||
child1() {
|
||||
Tasks() {
|
||||
help() {
|
||||
buildEnvironment()
|
||||
components()
|
||||
dependencies()
|
||||
dependencyInsight()
|
||||
dependentComponents()
|
||||
help()
|
||||
model()
|
||||
projects()
|
||||
properties()
|
||||
tasks()
|
||||
}
|
||||
}
|
||||
}
|
||||
child2() {
|
||||
Tasks() {
|
||||
help() {
|
||||
buildEnvironment()
|
||||
components()
|
||||
dependencies()
|
||||
dependencyInsight()
|
||||
dependentComponents()
|
||||
help()
|
||||
model()
|
||||
projects()
|
||||
properties()
|
||||
tasks()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,6 +184,35 @@ version '1.0-SNAPSHOT'
|
||||
assert ModuleManager.getInstance(myProject).getModules().length == 3
|
||||
}
|
||||
|
||||
@Test
|
||||
@TargetVersions("5.0")
|
||||
void testWithExistedRootModuleWithoutPreviewImport() {
|
||||
createMainModule("project")
|
||||
|
||||
createSettingsFile("""
|
||||
rootProject.name='rooot'
|
||||
include ':child1'
|
||||
include ':child2'"""
|
||||
)
|
||||
|
||||
createProjectSubFile "build.gradle", """
|
||||
group 'test'
|
||||
version '1.0-SNAPSHOT'
|
||||
"""
|
||||
|
||||
createProjectSubFile "../child1/build.gradle", """
|
||||
group 'test'
|
||||
version '1.0-SNAPSHOT'
|
||||
"""
|
||||
createProjectSubFile "../child2/build.gradle", """
|
||||
group 'test'
|
||||
version '1.0-SNAPSHOT'
|
||||
"""
|
||||
|
||||
doTest()
|
||||
assert ModuleManager.getInstance(myProject).getModules().length == 3
|
||||
}
|
||||
|
||||
Module createMainModule(String name) {
|
||||
Module module = null
|
||||
WriteAction.runAndWait {
|
||||
|
||||
Reference in New Issue
Block a user