From e60f40535f220310444a50c8d8b12f1656c94a40 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Wed, 16 Jan 2013 15:28:06 +0100 Subject: [PATCH] explicitly adding project sdk to the candidate sdk list when launching external build process; more robust launching error processing --- .../src/com/intellij/compiler/impl/CompileDriver.java | 5 ++--- .../src/com/intellij/compiler/server/BuildManager.java | 10 ++++++++-- .../src/org/jetbrains/jps/api/CmdlineProtoUtil.java | 10 ++++++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java index 568bb42b28a0..346641f66bb2 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java @@ -521,11 +521,10 @@ public class CompileDriver { @Override public void handleFailure(UUID sessionId, CmdlineRemoteProto.Message.Failure failure) { - compileContext.addMessage(CompilerMessageCategory.ERROR, failure.getDescription(), null, -1, -1); - final String trace = failure.getStacktrace(); + compileContext.addMessage(CompilerMessageCategory.ERROR, failure.hasDescription()? failure.getDescription() : "", null, -1, -1); + final String trace = failure.hasStacktrace()? failure.getStacktrace() : null; if (trace != null) { LOG.info(trace); - System.out.println(trace); } compileContext.putUserData(COMPILE_SERVER_BUILD_STATUS, ExitStatus.ERRORS); } diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java index c33b1de3f854..5cc6610b558f 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java @@ -554,7 +554,7 @@ public class BuildManager implements ApplicationComponent{ projectTaskQueue.submit(new Runnable() { @Override public void run() { - ExecutionException execFailure = null; + Throwable execFailure = null; try { if (project.isDisposed()) { return; @@ -595,7 +595,7 @@ public class BuildManager implements ApplicationComponent{ handler.handleFailure(sessionId, CmdlineProtoUtil.createFailure("Disconnected from build process", null)); } } - catch (ExecutionException e) { + catch (Throwable e) { execFailure = e; } finally { @@ -690,12 +690,18 @@ public class BuildManager implements ApplicationComponent{ int sdkMinorVersion = 0; final Set candidates = new HashSet(); + final Sdk defaultSdk = ProjectRootManager.getInstance(project).getProjectSdk(); + if (defaultSdk != null && defaultSdk.getSdkType() instanceof JavaSdk) { + candidates.add(defaultSdk); + } + for (Module module : ModuleManager.getInstance(project).getModules()) { final Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); if (sdk != null && sdk.getSdkType() instanceof JavaSdk) { candidates.add(sdk); } } + // now select the latest version from the sdks that are used in the project, but not older than the internal sdk version for (Sdk candidate : candidates) { final String vs = candidate.getVersionString(); diff --git a/jps/jps-builders/src/org/jetbrains/jps/api/CmdlineProtoUtil.java b/jps/jps-builders/src/org/jetbrains/jps/api/CmdlineProtoUtil.java index bc71808cf346..46397f75509b 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/api/CmdlineProtoUtil.java +++ b/jps/jps-builders/src/org/jetbrains/jps/api/CmdlineProtoUtil.java @@ -127,7 +127,9 @@ public class CmdlineProtoUtil { public static CmdlineRemoteProto.Message.Failure createFailure(String description, @Nullable Throwable cause) { final CmdlineRemoteProto.Message.Failure.Builder builder = CmdlineRemoteProto.Message.Failure.newBuilder(); - builder.setDescription(description); + if (description != null) { + builder.setDescription(description); + } if (cause != null) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final PrintStream stream = new PrintStream(baos); @@ -137,7 +139,11 @@ public class CmdlineProtoUtil { finally { stream.close(); } - builder.setStacktrace(new String(baos.toByteArray())); + final String stacktrace = new String(baos.toByteArray()); + builder.setStacktrace(stacktrace); + if (description == null) { + builder.setDescription(stacktrace); + } } return builder.build(); }