Moved CompilerDependencies.findRtJar() method to PathUtil.

This commit is contained in:
Evgeny Gerashchenko
2012-07-04 15:27:10 +04:00
parent 701ddc6376
commit c833ca251f
5 changed files with 38 additions and 36 deletions
@@ -102,36 +102,8 @@ public class CompilerDependencies {
public static CompilerDependencies compilerDependenciesForProduction(@NotNull CompilerSpecialMode compilerSpecialMode) {
return new CompilerDependencies(
compilerSpecialMode,
compilerSpecialMode.includeJdk() ? findRtJar() : null,
compilerSpecialMode.includeJdk() ? PathUtil.findRtJar() : null,
compilerSpecialMode.includeJdkAnnotations() ? PathUtil.getJdkAnnotationsPath() : null,
compilerSpecialMode.includeKotlinRuntime() ? PathUtil.getDefaultRuntimePath() : null);
}
public static File findRtJar() {
String javaHome = System.getProperty("java.home");
if ("jre".equals(new File(javaHome).getName())) {
javaHome = new File(javaHome).getParent();
}
File rtJar = findRtJar(javaHome);
if (rtJar == null || !rtJar.exists()) {
throw new IllegalArgumentException("No JDK rt.jar found under " + javaHome);
}
return rtJar;
}
private static File findRtJar(String javaHome) {
File rtJar = new File(javaHome, "jre/lib/rt.jar");
if (rtJar.exists()) {
return rtJar;
}
File classesJar = new File(new File(javaHome).getParentFile().getAbsolutePath(), "Classes/classes.jar");
if (classesJar.exists()) {
return classesJar;
}
return null;
}
}