explicitly adding project sdk to the candidate sdk list when launching external build process;

more robust launching error processing
This commit is contained in:
Eugene Zhuravlev
2013-01-16 15:33:21 +01:00
parent 38f4b9ea6e
commit e60f40535f
3 changed files with 18 additions and 7 deletions
@@ -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);
}
@@ -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<Sdk> candidates = new HashSet<Sdk>();
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();
@@ -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();
}