build tests: don't add dummy classes root when running under JDK 9 (IDEA-CR-20468)

Previously 'file://null' URL was added to JDK classes roots, it looks strange and may lead to problems.
This commit is contained in:
nik
2017-04-25 15:59:43 +03:00
parent ead4261db9
commit 11926a141e
@@ -173,7 +173,8 @@ public abstract class JpsBuildTestCase extends UsefulTestCase {
protected JpsSdk<JpsDummyElement> addJdk(final String name) {
try {
String path = ClasspathBootstrap.getResourcePath(Object.class) == null ? null : FileUtil.toSystemIndependentName(ClasspathBootstrap.getResourceFile(Object.class).getCanonicalPath());
String pathToRtJar = ClasspathBootstrap.getResourcePath(Object.class);
String path = pathToRtJar == null ? null : FileUtil.toSystemIndependentName(new File(pathToRtJar).getCanonicalPath());
return addJdk(name, path);
}
catch (IOException e) {
@@ -181,11 +182,13 @@ public abstract class JpsBuildTestCase extends UsefulTestCase {
}
}
protected JpsSdk<JpsDummyElement> addJdk(final String name, final String path) {
protected JpsSdk<JpsDummyElement> addJdk(final String name, @Nullable String jdkClassesRoot) {
String homePath = System.getProperty("java.home");
String versionString = System.getProperty("java.version");
JpsTypedLibrary<JpsSdk<JpsDummyElement>> jdk = myModel.getGlobal().addSdk(name, homePath, versionString, JpsJavaSdkType.INSTANCE);
jdk.addRoot(JpsPathUtil.pathToUrl(path), JpsOrderRootType.COMPILED);
if (jdkClassesRoot != null) {
jdk.addRoot(JpsPathUtil.pathToUrl(jdkClassesRoot), JpsOrderRootType.COMPILED);
}
return jdk.getProperties();
}