diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java index 581bece8181c..cb88c8e7ec82 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java @@ -69,6 +69,25 @@ public class EPathUtil { return secondSlIdx != -1 && secondSlIdx + 1 < path.length() ? path.substring(secondSlIdx + 1) : null; } + public static boolean areUrlsPointTheSame(String ideaUrl, String eclipseUrl) { + final String path = VfsUtil.urlToPath(eclipseUrl); + if (ideaUrl.contains(path)) { + return true; + } + else { + final String relativeToModulePath = getRelativeToModulePath(path); + final int relativeIdx = ideaUrl.indexOf(relativeToModulePath); + if (relativeIdx != -1) { + final String pathToProjectFile = VfsUtil.urlToPath(ideaUrl.substring(0, relativeIdx)); + if (Comparing.strEqual(getRelativeModuleName(path), + EclipseProjectFinder.findProjectName(pathToProjectFile))) { + return true; + } + } + } + return false; + } + @Nullable static String expandEclipseRelative2ContentRoots(final @NotNull List currentRoots, final @NotNull String rootPath, diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java index f9fbc3c0563c..6fa09e58a0d7 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java @@ -48,6 +48,8 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; +import static org.jetbrains.idea.eclipse.conversion.EPathUtil.areUrlsPointTheSame; + /** * Read/write .eml */ @@ -142,7 +144,7 @@ public class IdeaSpecificSettings { for (Object r : libElement.getChildren(SRCROOT_ATTR)) { final String url = ((Element)r).getAttributeValue("url"); modifiableModel.addRoot(url, OrderRootType.SOURCES); - if (srcUrlsFromClasspath != null && srcUrlsFromClasspath.length == 1 && url.contains(VfsUtil.urlToPath(srcUrlsFromClasspath[0]))) { //remove compound root + if (srcUrlsFromClasspath != null && srcUrlsFromClasspath.length == 1 && areUrlsPointTheSame(url, srcUrlsFromClasspath[0])) { //remove compound root modifiableModel.removeRoot(srcUrlsFromClasspath[0], OrderRootType.SOURCES); srcUrlsFromClasspath = null; } @@ -295,8 +297,8 @@ public class IdeaSpecificSettings { for (Object r : libElement.getChildren(relativeModuleName)) { final String root = PathMacroManager.getInstance(project).expandPath(((Element)r).getAttributeValue(PROJECT_RELATED)); for (Iterator iterator = urls.iterator(); iterator.hasNext();) { - String url = iterator.next(); - if (root.contains(VfsUtil.urlToPath(url))) { + final String url = iterator.next(); + if (areUrlsPointTheSame(root, url)) { iterator.remove(); modifiableModel.removeRoot(url, orderRootType); modifiableModel.addRoot(root, orderRootType); diff --git a/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/anotherPath/.project b/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/anotherPath/.project new file mode 100644 index 000000000000..3c7030a86519 --- /dev/null +++ b/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/anotherPath/.project @@ -0,0 +1,17 @@ + + + ws-internals + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/anotherPath/lib/ant-contrib-1.0/ant-contrib-1.0b3-src.zip b/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/anotherPath/lib/ant-contrib-1.0/ant-contrib-1.0b3-src.zip new file mode 100644 index 000000000000..7ac0b0c0cafd Binary files /dev/null and b/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/anotherPath/lib/ant-contrib-1.0/ant-contrib-1.0b3-src.zip differ diff --git a/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/sourceRootPaths/.classpath b/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/sourceRootPaths/.classpath new file mode 100644 index 000000000000..ccae0d4b9300 --- /dev/null +++ b/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/sourceRootPaths/.classpath @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/sourceRootPaths/.project b/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/sourceRootPaths/.project new file mode 100644 index 000000000000..26c656303ab6 --- /dev/null +++ b/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/sourceRootPaths/.project @@ -0,0 +1,17 @@ + + + sourceRootPaths + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/sourceRootPaths/lib/jar-all-5.zip b/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/sourceRootPaths/lib/jar-all-5.zip new file mode 100644 index 000000000000..1c4f645ac0c7 Binary files /dev/null and b/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/sourceRootPaths/lib/jar-all-5.zip differ diff --git a/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/sourceRootPaths/sourceRootPaths.eml b/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/sourceRootPaths/sourceRootPaths.eml new file mode 100644 index 000000000000..e6557a2c0aa3 --- /dev/null +++ b/plugins/eclipse/testData/eml/anotherSourceRootPaths/srcPath/sourceRootPaths/sourceRootPaths.eml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/Eclipse2ModulesTest.java b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/Eclipse2ModulesTest.java index ff7c932a4f03..0245ec69d03e 100644 --- a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/Eclipse2ModulesTest.java +++ b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/Eclipse2ModulesTest.java @@ -40,6 +40,7 @@ import java.io.IOException; public abstract class Eclipse2ModulesTest extends IdeaTestCase { @NonNls protected static final String DEPEND_MODULE_NAME = "ws-internals"; + private String myDependantModulePath = "ws-internals"; protected abstract String getTestPath(); @@ -76,7 +77,7 @@ public abstract class Eclipse2ModulesTest extends IdeaTestCase { public VirtualFile compute() { final VirtualFile baseDir = getProject().getBaseDir(); assert baseDir != null; - return LocalFileSystem.getInstance().refreshAndFindFileByPath(baseDir.getPath() + "/" + workspaceRoot + "/ws-internals"); + return LocalFileSystem.getInstance().refreshAndFindFileByPath(baseDir.getPath() + "/" + workspaceRoot + "/" + myDependantModulePath); } } ); @@ -92,4 +93,8 @@ public abstract class Eclipse2ModulesTest extends IdeaTestCase { } }); } + + public void setDependantModulePath(String dependantModulePath) { + myDependantModulePath = dependantModulePath; + } } \ No newline at end of file diff --git a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseEml2ModulesTest.java b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseEml2ModulesTest.java index 90eac7649e0a..506d66c1c1db 100644 --- a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseEml2ModulesTest.java +++ b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseEml2ModulesTest.java @@ -35,4 +35,9 @@ public class EclipseEml2ModulesTest extends Eclipse2ModulesTest{ public void testSourceRootPaths() throws Exception { doTest("srcPath", "sourceRootPaths"); } + + public void testAnotherSourceRootPaths() throws Exception { + setDependantModulePath("anotherPath"); + doTest("srcPath", "sourceRootPaths"); + } } \ No newline at end of file