mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
External system: add support for different naming of external entities within IDEA models.
E.g. external lib name: 'somelib' -> IDEA lib name: 'Gradle: somelib'. external module name: 'some/module' -> IDEA module name: 'some_module'.
This commit is contained in:
+32
-1
@@ -58,17 +58,48 @@ public abstract class AbstractDependencyData<T extends AbstractExternalEntityDat
|
||||
myExported = exported;
|
||||
}
|
||||
|
||||
/**
|
||||
* please use {@link #getExternalName()} or {@link #getInternalName()} instead
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
@Override
|
||||
public String getName() {
|
||||
return myTarget.getName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* please use {@link #setExternalName(String)} or {@link #setInternalName(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setName(@NotNull String name) {
|
||||
myTarget.setName(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getExternalName() {
|
||||
return myTarget.getExternalName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExternalName(@NotNull String name) {
|
||||
myTarget.setExternalName(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalName() {
|
||||
return myTarget.getInternalName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInternalName(@NotNull String name) {
|
||||
myTarget.setInternalName(name);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("MethodOverridesPrivateMethodOfSuperclass")
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
|
||||
+53
-11
@@ -10,29 +10,68 @@ import org.jetbrains.annotations.NotNull;
|
||||
public abstract class AbstractNamedData extends AbstractExternalEntityData implements Named {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String myName;
|
||||
|
||||
public AbstractNamedData(@NotNull ProjectSystemId owner, @NotNull String name) {
|
||||
@NotNull
|
||||
private String myExternalName;
|
||||
@NotNull
|
||||
private String myInternalName;
|
||||
|
||||
public AbstractNamedData(@NotNull ProjectSystemId owner, @NotNull String externalName) {
|
||||
this(owner, externalName, externalName);
|
||||
}
|
||||
|
||||
public AbstractNamedData(@NotNull ProjectSystemId owner, @NotNull String externalName, @NotNull String internalName) {
|
||||
super(owner);
|
||||
myName = name;
|
||||
myExternalName = externalName;
|
||||
myInternalName = internalName;
|
||||
}
|
||||
|
||||
/**
|
||||
* please use {@link #getExternalName()} or {@link #getInternalName()} instead
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
@Override
|
||||
public String getName() {
|
||||
return getExternalName();
|
||||
}
|
||||
|
||||
/**
|
||||
* please use {@link #setExternalName(String)} or {@link #setInternalName(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setName(@NotNull String name) {
|
||||
setExternalName(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
public String getExternalName() {
|
||||
return myExternalName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(@NotNull String name) {
|
||||
myName = name;
|
||||
public void setExternalName(@NotNull String name) {
|
||||
myExternalName = name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalName() {
|
||||
return myInternalName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInternalName(@NotNull String name) {
|
||||
myInternalName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + myName.hashCode();
|
||||
result = 31 * result + myExternalName.hashCode();
|
||||
result = 31 * result + myInternalName.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -40,7 +79,10 @@ public abstract class AbstractNamedData extends AbstractExternalEntityData imple
|
||||
public boolean equals(Object o) {
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
AbstractNamedData that = (AbstractNamedData)o;
|
||||
return myName.equals(that.myName);
|
||||
AbstractNamedData data = (AbstractNamedData)o;
|
||||
|
||||
if (!myExternalName.equals(data.myExternalName)) return false;
|
||||
if (!myInternalName.equals(data.myInternalName)) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class ExternalProjectPojo implements Comparable<ExternalProjectPojo> {
|
||||
|
||||
@NotNull
|
||||
public static <T extends Named & ExternalConfigPathAware & Identifiable> ExternalProjectPojo from(@NotNull T data) {
|
||||
String projectUniqueName = StringUtil.isEmpty(data.getId()) ? data.getName() : data.getId();
|
||||
String projectUniqueName = StringUtil.isEmpty(data.getId()) ? data.getExternalName() : data.getId();
|
||||
return new ExternalProjectPojo(projectUniqueName, data.getLinkedExternalProjectPath());
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ public class LibraryData extends AbstractNamedData implements Named {
|
||||
}
|
||||
|
||||
public LibraryData(@NotNull ProjectSystemId owner, @NotNull String name, boolean unresolved) {
|
||||
super(owner, name);
|
||||
super(owner, name, String.format("%s: %s", owner.getReadableName(), name));
|
||||
myUnresolved = unresolved;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,6 @@ public class LibraryData extends AbstractNamedData implements Named {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("library %s%s", getName(), myUnresolved ? "(unresolved)" : "");
|
||||
return String.format("library %s%s", getExternalName(), myUnresolved ? "(unresolved)" : "");
|
||||
}
|
||||
}
|
||||
|
||||
+3
-10
@@ -22,7 +22,6 @@ public class ModuleData extends AbstractNamedData implements Named, ExternalConf
|
||||
|
||||
@NotNull private final Map<ExternalSystemSourceType, String> 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;
|
||||
@@ -47,9 +46,8 @@ public class ModuleData extends AbstractNamedData implements Named, ExternalConf
|
||||
@NotNull String name,
|
||||
@NotNull String moduleFileDirectoryPath,
|
||||
@NotNull String externalConfigPath) {
|
||||
super(owner, name);
|
||||
super(owner, name, name.replaceAll("(/|\\\\)", "_"));
|
||||
myId = id;
|
||||
myIdeModuleFileName = name.replaceAll("(/|\\\\)", "_");
|
||||
myModuleTypeId = typeId;
|
||||
myExternalConfigPath = externalConfigPath;
|
||||
myArtifacts = Collections.emptyList();
|
||||
@@ -62,11 +60,6 @@ public class ModuleData extends AbstractNamedData implements Named, ExternalConf
|
||||
return myId;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getIdeModuleFileName() {
|
||||
return myIdeModuleFileName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getModuleTypeId() {
|
||||
return myModuleTypeId;
|
||||
@@ -84,7 +77,7 @@ public class ModuleData extends AbstractNamedData implements Named, ExternalConf
|
||||
}
|
||||
|
||||
public void setModuleFileDirectoryPath(@NotNull String path) {
|
||||
myModuleFilePath = ExternalSystemApiUtil.toCanonicalPath(path + "/" + myIdeModuleFileName + ModuleFileType.DOT_DEFAULT_EXTENSION);
|
||||
myModuleFilePath = ExternalSystemApiUtil.toCanonicalPath(path + "/" + getInternalName() + ModuleFileType.DOT_DEFAULT_EXTENSION);
|
||||
}
|
||||
|
||||
public boolean isInheritProjectCompileOutputPath() {
|
||||
@@ -170,7 +163,7 @@ public class ModuleData extends AbstractNamedData implements Named, ExternalConf
|
||||
public String toString() {
|
||||
return String.format("module '%s:%s:%s'",
|
||||
group == null ? "" : group,
|
||||
getName(),
|
||||
getExternalName(),
|
||||
version == null ? "" : version);
|
||||
}
|
||||
}
|
||||
|
||||
-7
@@ -10,13 +10,6 @@ import java.util.Comparator;
|
||||
*/
|
||||
public class ModuleDependencyData extends AbstractDependencyData<ModuleData> {
|
||||
|
||||
public static final Comparator<ModuleDependencyData> COMPARATOR = new Comparator<ModuleDependencyData>() {
|
||||
@Override
|
||||
public int compare(ModuleDependencyData o1, ModuleDependencyData o2) {
|
||||
return Named.COMPARATOR.compare(o1.getTarget(), o2.getTarget());
|
||||
}
|
||||
};
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ModuleDependencyData(@NotNull ModuleData ownerModule, @NotNull ModuleData module) {
|
||||
|
||||
+16
-10
@@ -12,18 +12,24 @@ import java.util.Comparator;
|
||||
*/
|
||||
public interface Named {
|
||||
|
||||
/** Key of the {@link #getName() name} property to use with {@link PropertyChangeListener#propertyChange(PropertyChangeEvent)}. */
|
||||
String NAME_PROPERTY = "Name";
|
||||
|
||||
Comparator<Named> COMPARATOR = new Comparator<Named>() {
|
||||
@Override
|
||||
public int compare(Named o1, Named o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* please use {@link #getExternalName()} or {@link #getInternalName()} instead
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* please use {@link #setExternalName(String)} or {@link #setInternalName(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
void setName(@NotNull String name);
|
||||
|
||||
@NotNull
|
||||
String getExternalName();
|
||||
void setExternalName(@NotNull String name);
|
||||
|
||||
@NotNull
|
||||
String getInternalName();
|
||||
void setInternalName(@NotNull String name);
|
||||
}
|
||||
|
||||
+20
-5
@@ -3,11 +3,10 @@ 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.
|
||||
*
|
||||
*
|
||||
* @author Denis Zhdanov
|
||||
* @since 8/1/11 1:30 PM
|
||||
*/
|
||||
@@ -19,15 +18,31 @@ public class ProjectData extends AbstractNamedData implements ExternalConfigPath
|
||||
|
||||
@NotNull private String myIdeProjectFileDirectoryPath;
|
||||
|
||||
@Deprecated
|
||||
public ProjectData(@NotNull ProjectSystemId owner,
|
||||
@NotNull String ideProjectFileDirectoryPath,
|
||||
@NotNull String linkedExternalProjectPath)
|
||||
{
|
||||
@NotNull String linkedExternalProjectPath) {
|
||||
super(owner, "unnamed");
|
||||
myLinkedExternalProjectPath = ExternalSystemApiUtil.toCanonicalPath(linkedExternalProjectPath);
|
||||
myIdeProjectFileDirectoryPath = ExternalSystemApiUtil.toCanonicalPath(ideProjectFileDirectoryPath);
|
||||
}
|
||||
|
||||
public ProjectData(@NotNull ProjectSystemId owner,
|
||||
@NotNull String externalName,
|
||||
@NotNull String ideProjectFileDirectoryPath,
|
||||
@NotNull String linkedExternalProjectPath) {
|
||||
super(owner, externalName);
|
||||
myLinkedExternalProjectPath = ExternalSystemApiUtil.toCanonicalPath(linkedExternalProjectPath);
|
||||
myIdeProjectFileDirectoryPath = ExternalSystemApiUtil.toCanonicalPath(ideProjectFileDirectoryPath);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setName(@NotNull String name) {
|
||||
super.setExternalName(name);
|
||||
super.setInternalName(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getIdeProjectFileDirectoryPath() {
|
||||
return myIdeProjectFileDirectoryPath;
|
||||
@@ -64,7 +79,7 @@ public class ProjectData extends AbstractNamedData implements ExternalConfigPath
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s project '%s'", getOwner().toString().toLowerCase(), getName());
|
||||
return String.format("%s project '%s'", getOwner().toString().toLowerCase(), getExternalName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+1
-11
@@ -167,18 +167,8 @@ public class ExternalSystemApiUtil {
|
||||
return "unknown-lib";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getLibraryName(@NotNull LibraryData libraryData) {
|
||||
return String.format("%s: %s", libraryData.getOwner().getReadableName(), libraryData.getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getLibraryName(@NotNull LibraryDependencyData libraryDependencyData) {
|
||||
return String.format("%s: %s", libraryDependencyData.getOwner().getReadableName(), libraryDependencyData.getName());
|
||||
}
|
||||
|
||||
public static boolean isRelated(@NotNull Library library, @NotNull LibraryData libraryData) {
|
||||
return getLibraryName(library).equals(getLibraryName(libraryData));
|
||||
return getLibraryName(library).equals(libraryData.getInternalName());
|
||||
}
|
||||
|
||||
public static boolean isExternalSystemLibrary(@NotNull Library library, @NotNull ProjectSystemId externalSystemId) {
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ public class ProjectStructureHelper {
|
||||
|
||||
@Nullable
|
||||
public Module findIdeModule(@NotNull ModuleData module, @NotNull Project ideProject) {
|
||||
return findIdeModule(module.getIdeModuleFileName(), ideProject);
|
||||
return findIdeModule(module.getInternalName(), ideProject);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -73,7 +73,7 @@ public class ProjectStructureHelper {
|
||||
for (OrderEntry entry : model.getOrderEntries()) {
|
||||
if (entry instanceof ModuleOrderEntry) {
|
||||
ModuleOrderEntry candidate = (ModuleOrderEntry)entry;
|
||||
if (dependency.getName().equals(candidate.getModuleName()) &&
|
||||
if (dependency.getInternalName().equals(candidate.getModuleName()) &&
|
||||
dependency.getScope().equals(candidate.getScope())) {
|
||||
return candidate;
|
||||
}
|
||||
|
||||
+2
-2
@@ -82,7 +82,7 @@ public class LibraryDataService implements ProjectDataService<LibraryData, Libra
|
||||
syncPaths(toImport, library, project, synchronous);
|
||||
return;
|
||||
}
|
||||
importLibrary(ExternalSystemApiUtil.getLibraryName(toImport), libraryFiles, project, synchronous);
|
||||
importLibrary(toImport.getInternalName(), libraryFiles, project, synchronous);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -227,7 +227,7 @@ public class LibraryDataService implements ProjectDataService<LibraryData, Libra
|
||||
for (Map.Entry<OrderRootType, Set<String>> entry : toAdd.entrySet()) {
|
||||
Map<OrderRootType, Collection<File>> roots = ContainerUtilRt.newHashMap();
|
||||
roots.put(entry.getKey(), ContainerUtil.map(entry.getValue(), PATH_TO_FILE));
|
||||
registerPaths(roots, model, ExternalSystemApiUtil.getLibraryName(externalLibrary));
|
||||
registerPaths(roots, model, externalLibrary.getInternalName());
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
+3
-3
@@ -132,7 +132,7 @@ public class LibraryDependencyDataService extends AbstractDependencyDataService<
|
||||
}
|
||||
break;
|
||||
case PROJECT:
|
||||
projectLibrariesToImport.put(ExternalSystemApiUtil.getLibraryName(libraryData) + dependencyData.getScope().name(), dependencyData);
|
||||
projectLibrariesToImport.put(libraryData.getInternalName() + dependencyData.getScope().name(), dependencyData);
|
||||
toImport.add(dependencyData);
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public class LibraryDependencyDataService extends AbstractDependencyDataService<
|
||||
{
|
||||
for (LibraryDependencyData dependencyData : toImport) {
|
||||
LibraryData libraryData = dependencyData.getTarget();
|
||||
String libraryName = ExternalSystemApiUtil.getLibraryName(libraryData);
|
||||
String libraryName = libraryData.getInternalName();
|
||||
switch (dependencyData.getLevel()) {
|
||||
case MODULE:
|
||||
@SuppressWarnings("ConstantConditions") Library moduleLib = moduleLibraryTable.createLibrary(libraryName);
|
||||
@@ -248,7 +248,7 @@ public class LibraryDependencyDataService extends AbstractDependencyDataService<
|
||||
if (dependencyData.getLevel() != LibraryLevel.PROJECT) {
|
||||
continue;
|
||||
}
|
||||
final Library library = libraryTable.getLibraryByName(ExternalSystemApiUtil.getLibraryName(dependencyData));
|
||||
final Library library = libraryTable.getLibraryByName(dependencyData.getInternalName());
|
||||
if (library == null) {
|
||||
DataNode<ProjectData> projectNode = dataNode.getDataNode(ProjectKeys.PROJECT);
|
||||
if (projectNode != null) {
|
||||
|
||||
+3
-3
@@ -93,7 +93,7 @@ public class ModuleDependencyDataService extends AbstractDependencyDataService<M
|
||||
@Override
|
||||
public void execute() {
|
||||
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
|
||||
Map<Pair<String /* dependency module name */, /* dependency module scope */DependencyScope> , ModuleOrderEntry> toRemove = ContainerUtilRt.newHashMap();
|
||||
Map<Pair<String /* dependency module internal name */, /* dependency module scope */DependencyScope> , ModuleOrderEntry> toRemove = ContainerUtilRt.newHashMap();
|
||||
for (OrderEntry entry : moduleRootManager.getOrderEntries()) {
|
||||
if (entry instanceof ModuleOrderEntry) {
|
||||
ModuleOrderEntry e = (ModuleOrderEntry)entry;
|
||||
@@ -105,8 +105,8 @@ public class ModuleDependencyDataService extends AbstractDependencyDataService<M
|
||||
try {
|
||||
for (DataNode<ModuleDependencyData> dependencyNode : toImport) {
|
||||
final ModuleDependencyData dependencyData = dependencyNode.getData();
|
||||
toRemove.remove(Pair.create(dependencyData.getName(), dependencyData.getScope()));
|
||||
final String moduleName = dependencyData.getName();
|
||||
toRemove.remove(Pair.create(dependencyData.getInternalName(), dependencyData.getScope()));
|
||||
final String moduleName = dependencyData.getInternalName();
|
||||
Module ideDependencyModule = myProjectStructureHelper.findIdeModule(moduleName, module.getProject());
|
||||
if (ideDependencyModule == null) {
|
||||
DataNode<ProjectData> projectNode = dependencyNode.getDataNode(ProjectKeys.PROJECT);
|
||||
|
||||
+2
-2
@@ -52,8 +52,8 @@ public class ProjectDataServiceImpl implements ProjectDataService<ProjectData, P
|
||||
return;
|
||||
}
|
||||
|
||||
if (!project.getName().equals(projectData.getName())) {
|
||||
renameProject(projectData.getName(), projectData.getOwner(), project, synchronous);
|
||||
if (!project.getName().equals(projectData.getInternalName())) {
|
||||
renameProject(projectData.getInternalName(), projectData.getOwner(), project, synchronous);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -375,7 +375,7 @@ public abstract class AbstractExternalProjectImportBuilder<C extends AbstractImp
|
||||
assert false;
|
||||
return;
|
||||
}
|
||||
context.setProjectName(myExternalProjectNode.getData().getName());
|
||||
context.setProjectName(myExternalProjectNode.getData().getInternalName());
|
||||
context.setProjectFileDirectory(myExternalProjectNode.getData().getIdeProjectFileDirectoryPath());
|
||||
applyExtraSettings(context);
|
||||
}
|
||||
|
||||
+1
-1
@@ -217,7 +217,7 @@ public class ExternalSystemTasksTree extends Tree implements Producer<ExternalTa
|
||||
}
|
||||
|
||||
// Disable tasks execution if it comes from different projects
|
||||
if(map.values().size() > 1) return null;
|
||||
if(map.values().size() != 1) return null;
|
||||
return map.values().iterator().next();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -60,8 +60,7 @@ class ExternalProjectBuilder extends BuilderSupport {
|
||||
switch (name) {
|
||||
case 'project':
|
||||
ProjectSystemId projectSystemId = attributes.projectSystemId ?: TEST_EXTERNAL_SYSTEM_ID
|
||||
ProjectData projectData = new ProjectData(projectSystemId, projectDir.path, projectDir.path)
|
||||
projectData.name = attributes.name ?: 'project'
|
||||
ProjectData projectData = new ProjectData(projectSystemId, attributes.name ?: 'project', projectDir.path, projectDir.path)
|
||||
projectNode = new DataNode<ProjectData>(ProjectKeys.PROJECT, projectData, null)
|
||||
return projectNode
|
||||
case 'module':
|
||||
@@ -107,7 +106,7 @@ class ExternalProjectBuilder extends BuilderSupport {
|
||||
@NotNull
|
||||
private LibraryData getLibrary(@NotNull String name, @NotNull Map attributes) {
|
||||
DataNode<LibraryData> existing = ExternalSystemApiUtil.find(projectNode, ProjectKeys.LIBRARY, {
|
||||
DataNode<LibraryData> node -> node.data.name == name
|
||||
DataNode<LibraryData> node -> node.data.externalName == name
|
||||
} as BooleanFunction)
|
||||
if (existing != null) {
|
||||
return existing.data
|
||||
|
||||
+10
-10
@@ -87,13 +87,13 @@ public class GradleLibraryNamesMixer {
|
||||
private static boolean doMixNames(@NotNull Collection<Wrapped> libraries, @NotNull Map<String, Wrapped> cache) {
|
||||
cache.clear();
|
||||
for (Wrapped current : libraries) {
|
||||
Wrapped previous = cache.remove(current.library.getName());
|
||||
Wrapped previous = cache.remove(current.library.getExternalName());
|
||||
if (previous == null) {
|
||||
cache.put(current.library.getName(), current);
|
||||
cache.put(current.library.getExternalName(), current);
|
||||
}
|
||||
else {
|
||||
mixNames(current, previous);
|
||||
return current.library.getName().equals(previous.library.getName()); // Stop processing if it's not possible to generate
|
||||
return current.library.getExternalName().equals(previous.library.getExternalName()); // Stop processing if it's not possible to generate
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -143,17 +143,17 @@ public class GradleLibraryNamesMixer {
|
||||
if (file1 == null) {
|
||||
wrapped1.nextFile();
|
||||
}
|
||||
else if (!wrapped1.library.getName().startsWith(file1.getName())) {
|
||||
wrapped1.library.setName(file1.getName() + NAME_SEPARATOR + wrapped1.library.getName());
|
||||
else if (!wrapped1.library.getExternalName().startsWith(file1.getName())) {
|
||||
wrapped1.library.setExternalName(file1.getName() + NAME_SEPARATOR + wrapped1.library.getExternalName());
|
||||
}
|
||||
if (file2 == null) {
|
||||
wrapped2.nextFile();
|
||||
}
|
||||
else if (!wrapped2.library.getName().startsWith(file2.getName())) {
|
||||
wrapped2.library.setName(file2.getName() + NAME_SEPARATOR + wrapped2.library.getName());
|
||||
else if (!wrapped2.library.getExternalName().startsWith(file2.getName())) {
|
||||
wrapped2.library.setExternalName(file2.getName() + NAME_SEPARATOR + wrapped2.library.getExternalName());
|
||||
}
|
||||
|
||||
if (wrapped1.library.getName().equals(wrapped2.library.getName())) {
|
||||
if (wrapped1.library.getExternalName().equals(wrapped2.library.getExternalName())) {
|
||||
if (wrapped1AltText != null) {
|
||||
diversifyName(wrapped1AltText, wrapped1, file1);
|
||||
return;
|
||||
@@ -175,7 +175,7 @@ public class GradleLibraryNamesMixer {
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private static void diversifyName(@NotNull String changeText, @NotNull Wrapped wrapped, @Nullable File file) {
|
||||
String name = wrapped.library.getName();
|
||||
String name = wrapped.library.getExternalName();
|
||||
int i = file == null ? - 1 : name.indexOf(file.getName());
|
||||
final String newName;
|
||||
if (i >= 0) {
|
||||
@@ -184,7 +184,7 @@ public class GradleLibraryNamesMixer {
|
||||
else {
|
||||
newName = changeText + NAME_SEPARATOR + name;
|
||||
}
|
||||
wrapped.library.setName(newName);
|
||||
wrapped.library.setExternalName(newName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-6
@@ -101,10 +101,7 @@ public class BaseGradleProjectResolverExtension implements GradleProjectResolver
|
||||
public ProjectData createProject() {
|
||||
final String projectDirPath = resolverCtx.getProjectPath();
|
||||
final IdeaProject ideaProject = resolverCtx.getModels().getIdeaProject();
|
||||
|
||||
ProjectData projectData = new ProjectData(GradleConstants.SYSTEM_ID, projectDirPath, projectDirPath);
|
||||
projectData.setName(ideaProject.getName());
|
||||
return projectData;
|
||||
return new ProjectData(GradleConstants.SYSTEM_ID, ideaProject.getName(), projectDirPath, projectDirPath);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -129,7 +126,7 @@ public class BaseGradleProjectResolverExtension implements GradleProjectResolver
|
||||
}
|
||||
final String moduleConfigPath = GradleUtil.getConfigPath(gradleModule.getGradleProject(), projectData.getLinkedExternalProjectPath());
|
||||
|
||||
if(ExternalSystemDebugEnvironment.DEBUG_ORPHAN_MODULES_PROCESSING) {
|
||||
if (ExternalSystemDebugEnvironment.DEBUG_ORPHAN_MODULES_PROCESSING) {
|
||||
LOG.info(String.format(
|
||||
"Creating module data ('%s') with the external config path: '%s'", gradleModule.getGradleProject().getPath(), moduleConfigPath
|
||||
));
|
||||
@@ -414,7 +411,7 @@ public class BaseGradleProjectResolverExtension implements GradleProjectResolver
|
||||
Set<String> registeredModuleNames = ContainerUtilRt.newHashSet();
|
||||
Collection<DataNode<ModuleData>> modulesDataNode = ExternalSystemApiUtil.getChildren(ideProject, ProjectKeys.MODULE);
|
||||
for (DataNode<ModuleData> moduleDataNode : modulesDataNode) {
|
||||
String name = moduleDataNode.getData().getName();
|
||||
String name = moduleDataNode.getData().getExternalName();
|
||||
registeredModuleNames.add(name);
|
||||
if (name.equals(moduleName)) {
|
||||
return new ModuleDependencyData(ownerModule.getData(), moduleDataNode.getData());
|
||||
|
||||
Reference in New Issue
Block a user