diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalProjectPojo.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalProjectPojo.java index 9f90872cb922..f30c7092ead4 100644 --- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalProjectPojo.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalProjectPojo.java @@ -15,14 +15,15 @@ */ package com.intellij.openapi.externalSystem.model.project; +import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; /** -* @author Denis Zhdanov -* @since 5/18/13 10:51 PM -*/ + * @author Denis Zhdanov + * @since 5/18/13 10:51 PM + */ public class ExternalProjectPojo implements Comparable { - + @NotNull private String myName; @NotNull private String myPath; @@ -38,10 +39,11 @@ public class ExternalProjectPojo implements Comparable { } @NotNull - public static ExternalProjectPojo from(@NotNull T data) { - return new ExternalProjectPojo(data.getName(), data.getLinkedExternalProjectPath()); + public static ExternalProjectPojo from(@NotNull T data) { + String projectUniqueName = StringUtil.isEmpty(data.getId()) ? data.getName() : data.getId(); + return new ExternalProjectPojo(projectUniqueName, data.getLinkedExternalProjectPath()); } - + @NotNull public String getName() { return myName; diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/Identifiable.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/Identifiable.java new file mode 100644 index 000000000000..3d1814402650 --- /dev/null +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/Identifiable.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.externalSystem.model.project; + +import org.jetbrains.annotations.NotNull; + +/** + * @author Vladislav.Soroka + * @since 11/27/13 + */ +public interface Identifiable { + + @NotNull + String getId(); +} diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ModuleData.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ModuleData.java index d9f1f9d81c4d..7de3b6310e9c 100644 --- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ModuleData.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ModuleData.java @@ -4,7 +4,6 @@ import com.intellij.ide.highlighter.ModuleFileType; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.ContainerUtilRt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -17,12 +16,13 @@ import java.util.Map; * @author Denis Zhdanov * @since 8/8/11 12:11 PM */ -public class ModuleData extends AbstractNamedData implements Named, ExternalConfigPathAware { +public class ModuleData extends AbstractNamedData implements Named, ExternalConfigPathAware, Identifiable { private static final long serialVersionUID = 1L; - @NotNull private final Map myCompileOutputPaths = ContainerUtilRt.newHashMap(); - + @NotNull private final Map myCompileOutputPaths = ContainerUtil.newHashMap(); + @NotNull private final String myId; + @NotNull private final String myIdeModuleFileName; @NotNull private final String myModuleTypeId; @NotNull private final String myExternalConfigPath; @NotNull private String myModuleFilePath; @@ -32,18 +32,41 @@ public class ModuleData extends AbstractNamedData implements Named, ExternalConf private boolean myInheritProjectCompileOutputPath = true; + @Deprecated public ModuleData(@NotNull ProjectSystemId owner, @NotNull String typeId, @NotNull String name, @NotNull String moduleFileDirectoryPath, @NotNull String externalConfigPath) { + this("", owner, typeId, name, moduleFileDirectoryPath, externalConfigPath); + } + + public ModuleData(@NotNull String id, + @NotNull ProjectSystemId owner, + @NotNull String typeId, + @NotNull String name, + @NotNull String moduleFileDirectoryPath, + @NotNull String externalConfigPath) { super(owner, name); + myId = id; + myIdeModuleFileName = name.replaceAll("(/|\\\\)", "_"); myModuleTypeId = typeId; myExternalConfigPath = externalConfigPath; myArtifacts = Collections.emptyList(); setModuleFileDirectoryPath(moduleFileDirectoryPath); } + @NotNull + @Override + public String getId() { + return myId; + } + + @NotNull + public String getIdeModuleFileName() { + return myIdeModuleFileName; + } + @NotNull public String getModuleTypeId() { return myModuleTypeId; @@ -61,7 +84,7 @@ public class ModuleData extends AbstractNamedData implements Named, ExternalConf } public void setModuleFileDirectoryPath(@NotNull String path) { - myModuleFilePath = ExternalSystemApiUtil.toCanonicalPath(path + "/" + getName() + ModuleFileType.DOT_DEFAULT_EXTENSION); + myModuleFilePath = ExternalSystemApiUtil.toCanonicalPath(path + "/" + myIdeModuleFileName + ModuleFileType.DOT_DEFAULT_EXTENSION); } public boolean isInheritProjectCompileOutputPath() { diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ProjectData.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ProjectData.java index 385043425595..86a257c4fa6c 100644 --- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ProjectData.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ProjectData.java @@ -3,6 +3,7 @@ package com.intellij.openapi.externalSystem.model.project; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Not thread-safe. @@ -10,7 +11,7 @@ import org.jetbrains.annotations.NotNull; * @author Denis Zhdanov * @since 8/1/11 1:30 PM */ -public class ProjectData extends AbstractNamedData implements ExternalConfigPathAware { +public class ProjectData extends AbstractNamedData implements ExternalConfigPathAware, Identifiable { private static final long serialVersionUID = 1L; @@ -65,4 +66,10 @@ public class ProjectData extends AbstractNamedData implements ExternalConfigPath public String toString() { return String.format("%s project '%s'", getOwner().toString().toLowerCase(), getName()); } + + @NotNull + @Override + public String getId() { + return ""; + } } diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureHelper.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureHelper.java index 54be23341dad..62d3b2b7cdc0 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureHelper.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureHelper.java @@ -9,6 +9,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.*; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; +import com.intellij.openapi.util.io.FileUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -28,7 +29,7 @@ public class ProjectStructureHelper { @Nullable public Module findIdeModule(@NotNull ModuleData module, @NotNull Project ideProject) { - return findIdeModule(module.getName(), ideProject); + return findIdeModule(module.getIdeModuleFileName(), ideProject); } @Nullable diff --git a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalProjectBuilder.groovy b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalProjectBuilder.groovy index 957f0724107a..b32ea87bcd9f 100644 --- a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalProjectBuilder.groovy +++ b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalProjectBuilder.groovy @@ -68,7 +68,8 @@ class ExternalProjectBuilder extends BuilderSupport { ProjectSystemId projectSystemId = attributes.projectSystemId ?: TEST_EXTERNAL_SYSTEM_ID String moduleFilePath = attributes.moduleFilePath ?: projectDir.path String externalConfigPath = attributes.externalConfigPath ?: projectDir.path - ModuleData moduleData = new ModuleData(projectSystemId, + ModuleData moduleData = new ModuleData(attributes.name ?: name as String, + projectSystemId, ModuleTypeId.JAVA_MODULE, attributes.name ?: name as String, moduleFilePath, diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java index 6b155a23092e..4b5da15c8a47 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java @@ -26,6 +26,7 @@ import com.intellij.openapi.externalSystem.model.ProjectKeys; import com.intellij.openapi.externalSystem.model.project.*; import com.intellij.openapi.externalSystem.model.task.TaskData; import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemDebugEnvironment; import com.intellij.openapi.externalSystem.util.Order; import com.intellij.openapi.module.EmptyModuleType; import com.intellij.openapi.module.JavaModuleType; @@ -128,7 +129,13 @@ public class BaseGradleProjectResolverExtension implements GradleProjectResolver } final String moduleConfigPath = GradleUtil.getConfigPath(gradleModule.getGradleProject(), projectData.getLinkedExternalProjectPath()); - ModuleData moduleData = new ModuleData(GradleConstants.SYSTEM_ID, + if(ExternalSystemDebugEnvironment.DEBUG_ORPHAN_MODULES_PROCESSING) { + LOG.info(String.format( + "Creating module data ('%s') with the external config path: '%s'", gradleModule.getGradleProject().getPath(), moduleConfigPath + )); + } + ModuleData moduleData = new ModuleData(gradleModule.getGradleProject().getPath(), + GradleConstants.SYSTEM_ID, StdModuleTypes.JAVA.getId(), moduleName, moduleConfigPath, diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java index 4cde2be85327..2b319b8fc780 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java @@ -29,6 +29,7 @@ import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotifica import com.intellij.openapi.externalSystem.model.task.TaskData; import com.intellij.openapi.externalSystem.service.project.ExternalSystemProjectResolver; import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemDebugEnvironment; import com.intellij.openapi.util.KeyValue; import com.intellij.openapi.util.Pair; import com.intellij.util.Function; @@ -204,6 +205,11 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver