diff --git a/plugins/eclipse/common-eclipse-util/src/AbstractEclipseClasspathReader.java b/plugins/eclipse/common-eclipse-util/src/AbstractEclipseClasspathReader.java index 161463d697c5..2c5144353427 100644 --- a/plugins/eclipse/common-eclipse-util/src/AbstractEclipseClasspathReader.java +++ b/plugins/eclipse/common-eclipse-util/src/AbstractEclipseClasspathReader.java @@ -71,7 +71,7 @@ public abstract class AbstractEclipseClasspathReader { boolean exported, String libName, String url, - String srcUrl, ExpandMacroToPathMap macroMap); + String srcUrl, String nativeRoot, ExpandMacroToPathMap macroMap); protected abstract String expandEclipsePath2Url(T rootModel, String path); @@ -178,7 +178,12 @@ public abstract class AbstractEclipseClasspathReader { } } - addModuleLibrary(rootModel, element, exported, getPresentableName(path, libs), url, srcUrl, macroMap); + String nativeRoot = getNativeLibraryRoot(element); + if (nativeRoot != null) { + nativeRoot = expandEclipsePath2Url(rootModel, nativeRoot); + } + + addModuleLibrary(rootModel, element, exported, getPresentableName(path, libs), url, srcUrl, nativeRoot, macroMap); } else if (kind.equals(EclipseXml.VAR_KIND)) { int slash = path.indexOf("/"); @@ -201,7 +206,11 @@ public abstract class AbstractEclipseClasspathReader { eclipseModuleManager.registerEclipseSrcVariablePath(srcUrl, srcPathAttr); } } - addModuleLibrary(rootModel, element, exported, libName, url, srcUrl, macroMap); + String nativeRoot = getNativeLibraryRoot(element); + if (nativeRoot != null) { + nativeRoot = expandEclipsePath2Url(rootModel, nativeRoot); + } + addModuleLibrary(rootModel, element, exported, libName, url, srcUrl, nativeRoot, macroMap); } else if (kind.equals(EclipseXml.CON_KIND)) { if (path.equals(EclipseXml.ECLIPSE_PLATFORM)) { @@ -242,6 +251,18 @@ public abstract class AbstractEclipseClasspathReader { } } + private static String getNativeLibraryRoot(Element element) { + final Element attributes = element.getChild(EclipseXml.ATTRIBUTES_TAG); + if (attributes != null) { + for (Element attributeElement : attributes.getChildren(EclipseXml.ATTRIBUTE_TAG)) { + if (EclipseXml.DLL_LINK.equals(attributeElement.getAttributeValue(EclipseXml.NAME_ATTR))) { + return attributeElement.getAttributeValue(EclipseXml.VALUE_ATTR); + } + } + } + return null; + } + protected static int srcVarStart(String srcPath) { return srcPath.startsWith("/") ? 1 : 0; } diff --git a/plugins/eclipse/common-eclipse-util/src/EclipseXml.java b/plugins/eclipse/common-eclipse-util/src/EclipseXml.java index 2c3cbaaddb7d..bf1132dbfd1a 100644 --- a/plugins/eclipse/common-eclipse-util/src/EclipseXml.java +++ b/plugins/eclipse/common-eclipse-util/src/EclipseXml.java @@ -76,4 +76,5 @@ public interface EclipseXml { @NonNls String LINKED_RESOURCES = "linkedResources"; @NonNls String LINK = "link"; @NonNls String JAVADOC_LOCATION = "javadoc_location"; + @NonNls String DLL_LINK = "org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY"; } diff --git a/plugins/eclipse/jps-plugin/src/org/jetbrains/jps/eclipse/model/JpsEclipseClasspathReader.java b/plugins/eclipse/jps-plugin/src/org/jetbrains/jps/eclipse/model/JpsEclipseClasspathReader.java index 07ab144cd401..579b8ed6bb69 100644 --- a/plugins/eclipse/jps-plugin/src/org/jetbrains/jps/eclipse/model/JpsEclipseClasspathReader.java +++ b/plugins/eclipse/jps-plugin/src/org/jetbrains/jps/eclipse/model/JpsEclipseClasspathReader.java @@ -151,6 +151,7 @@ class JpsEclipseClasspathReader extends AbstractEclipseClasspathReader() { + @Override + public String fun(String s) { + return toEclipseJavadocPath(model, s); + } + }, JAVADOC_LOCATION, libraryOrderEntry.getRootUrls(JavadocOrderRootType.getInstance())); + } + + static void setupAttributes(Element orderEntry, + Function fun, + String attributeName, + String[] roots) { final List eclipseUrls = new ArrayList(); - final String[] docUrls = libraryOrderEntry.getRootUrls(JavadocOrderRootType.getInstance()); - if (docUrls.length > 0) { - eclipseUrls.add(toEclipseJavadocPath(model, docUrls[0])); + if (roots.length > 0) { + eclipseUrls.add(fun.fun(roots[0])); } final List children = new ArrayList(orderEntry.getChildren(ATTRIBUTES_TAG)); @@ -214,7 +226,7 @@ public class EJavadocUtil { final ArrayList attTags = new ArrayList(attsElement.getChildren(ATTRIBUTE_TAG)); for (Object a : attTags) { Element attElement = (Element)a; - if (Comparing.strEqual(attElement.getAttributeValue("name"), JAVADOC_LOCATION)) { + if (Comparing.strEqual(attElement.getAttributeValue("name"), attributeName)) { final String javadocPath = attElement.getAttributeValue("value"); if (!eclipseUrls.remove(javadocPath)) { attElement.detach(); @@ -232,7 +244,7 @@ public class EJavadocUtil { final Element attrElement = new Element(ATTRIBUTE_TAG); child.addContent(attrElement); - attrElement.setAttribute("name", JAVADOC_LOCATION); + attrElement.setAttribute("name", attributeName); attrElement.setAttribute("value", docUrl); } } diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java index 5cc1dbd15f23..9e1edbe36352 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java @@ -153,13 +153,20 @@ public class EclipseClasspathReader extends AbstractEclipseClasspathReader 0) { + EJavadocUtil.setupAttributes(orderEntry, new Function() { + @Override + public String fun(String nativeRoot) { + return EPathUtil.collapse2EclipsePath(nativeRoot, model); + } + }, EclipseXml.DLL_LINK, nativeRoots); + } setExported(orderEntry, libraryOrderEntry); } } diff --git a/plugins/eclipse/testData/round/nativeLibs/test/.classpath b/plugins/eclipse/testData/round/nativeLibs/test/.classpath new file mode 100644 index 000000000000..e7e908d65fa8 --- /dev/null +++ b/plugins/eclipse/testData/round/nativeLibs/test/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/eclipse/testData/round/nativeLibs/test/.project b/plugins/eclipse/testData/round/nativeLibs/test/.project new file mode 100644 index 000000000000..4766dbaa2c60 --- /dev/null +++ b/plugins/eclipse/testData/round/nativeLibs/test/.project @@ -0,0 +1,15 @@ + + + test + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.jdt.core.javanature + + diff --git a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseClasspathTest.java b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseClasspathTest.java index bf0340c9522e..03c1c7269ae8 100644 --- a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseClasspathTest.java +++ b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseClasspathTest.java @@ -150,6 +150,10 @@ public class EclipseClasspathTest extends IdeaTestCase { doTest(); } + public void testNativeLibs() throws Exception { + doTest(); + } + public void testAccessrulez() throws Exception { doTest(); }