external build: corrected check for internal JDK, excessive logging removed

This commit is contained in:
nik
2015-02-19 11:12:53 +03:00
parent db78755a84
commit 27ac327089
@@ -901,14 +901,8 @@ public class BuildManager implements ApplicationComponent{
// now select the latest version from the sdks that are used in the project, but not older than the internal sdk version
final JavaSdk javaSdkType = JavaSdk.getInstance();
if (IS_UNIT_TEST_MODE) {
LOG.info("detecting JDK");
}
for (Sdk candidate : candidates) {
final String vs = candidate.getVersionString();
if (IS_UNIT_TEST_MODE) {
LOG.info(" candidate=" + candidate);
}
if (vs != null) {
final JavaSdkVersion candidateVersion = javaSdkType.getVersion(vs);
if (candidateVersion != null) {
@@ -931,32 +925,22 @@ public class BuildManager implements ApplicationComponent{
}
final Sdk internalJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
if (IS_UNIT_TEST_MODE) {
LOG.info("projectJdk = " + projectJdk);
LOG.info("internalJdk = " + internalJdk);
}
if (projectJdk == null || sdkVersion == null || !sdkVersion.isAtLeast(JavaSdkVersion.JDK_1_6)) {
projectJdk = internalJdk;
}
// validate tools.jar presence
final JavaSdkType projectJdkType = (JavaSdkType)projectJdk.getSdkType();
if (projectJdk.equals(internalJdk)) {
if (FileUtil.pathsEqual(projectJdk.getHomePath(), internalJdk.getHomePath())) {
// important: because internal JDK can be either JDK or JRE,
// this is the most universal way to obtain tools.jar path in this particular case
final JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler();
if (systemCompiler == null) {
throw new ExecutionException("No system java compiler is provided by the JRE. Make sure tools.jar is present in IntelliJ IDEA classpath.");
}
if (IS_UNIT_TEST_MODE) {
LOG.info("compute compiler path by jar for " + systemCompiler.getClass());
}
compilerPath = ClasspathBootstrap.getResourcePath(systemCompiler.getClass());
}
else {
if (IS_UNIT_TEST_MODE) {
LOG.info("compute compiler path from jdk " + projectJdk + ", jdk home = " + projectJdk.getHomePath());
}
compilerPath = projectJdkType.getToolsPath(projectJdk);
if (compilerPath == null) {
throw new ExecutionException("Cannot determine path to 'tools.jar' library for " + projectJdk.getName() + " (" + projectJdk.getHomePath() + ")");
@@ -966,15 +950,10 @@ public class BuildManager implements ApplicationComponent{
vmExecutablePath = projectJdkType.getVMExecutablePath(projectJdk);
}
else {
if (IS_UNIT_TEST_MODE) {
LOG.info("use forced jdk home " + forcedCompiledJdkHome);
}
compilerPath = new File(forcedCompiledJdkHome, "lib/tools.jar").getAbsolutePath();
vmExecutablePath = new File(forcedCompiledJdkHome, "bin/java").getAbsolutePath();
}
if (IS_UNIT_TEST_MODE) {
LOG.info("compilerPath=" + compilerPath);
}
final CompilerWorkspaceConfiguration config = CompilerWorkspaceConfiguration.getInstance(project);
final GeneralCommandLine cmdLine = new GeneralCommandLine();
cmdLine.setExePath(vmExecutablePath);