correctly determine the path to compiler when starting build process

This commit is contained in:
Eugene Zhuravlev
2012-05-12 12:44:23 +02:00
parent 8ffa203245
commit 0b96eda9bc
4 changed files with 27 additions and 19 deletions
@@ -643,7 +643,8 @@ public class CompileServerManager implements ApplicationComponent{
cmdLine.addParameter("-classpath");
final List<File> cp = ClasspathBootstrap.getCompileServerApplicationClasspath();
final List<File> cp = ClasspathBootstrap.getBuildProcessApplicationClasspath();
cp.add(ClasspathBootstrap.getResourcePath(systemCompiler.getClass())); // tools.jar
cp.addAll(myClasspathManager.getCompileServerPluginsClasspath());
cmdLine.addParameter(classpathToString(cp));
@@ -565,14 +565,10 @@ public class BuildManager implements ApplicationComponent{
}
private Process launchBuildProcess(Project project, final int port, final UUID sessionId) throws ExecutionException {
// validate tools.jar presence
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.");
}
// choosing sdk with which the build process should be run
Sdk projectJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
final Sdk internalJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
Sdk projectJdk = internalJdk;
final String versionString = projectJdk.getVersionString();
if (versionString != null) {
JavaSdkVersion sdkVersion = ((JavaSdk)projectJdk.getSdkType()).getVersion(versionString);
@@ -600,6 +596,23 @@ public class BuildManager implements ApplicationComponent{
}
}
// validate tools.jar presence
final File compilerPath;
if (projectJdk.equals(internalJdk)) {
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.");
}
compilerPath = ClasspathBootstrap.getResourcePath(systemCompiler.getClass());
}
else {
final String path = ((JavaSdk)projectJdk.getSdkType()).getToolsPath(projectJdk);
if (path == null) {
throw new ExecutionException("Cannot determine path to 'tools.jar' library for " + projectJdk.getName() + " (" + projectJdk.getHomePath() + ")");
}
compilerPath = new File(path);
}
final GeneralCommandLine cmdLine = new GeneralCommandLine();
final String vmExecutablePath = ((JavaSdkType)projectJdk.getSdkType()).getVMExecutablePath(projectJdk);
cmdLine.setExePath(vmExecutablePath);
@@ -667,7 +680,8 @@ public class BuildManager implements ApplicationComponent{
cmdLine.addParameter("-classpath");
final List<File> cp = ClasspathBootstrap.getCompileServerApplicationClasspath();
final List<File> cp = ClasspathBootstrap.getBuildProcessApplicationClasspath();
cp.add(compilerPath);
cp.addAll(myClasspathManager.getCompileServerPluginsClasspath());
cmdLine.addParameter(classpathToString(cp));