Make sure that any exception during the final packaging properly put an error marker on the project (since build failed.

This commit is contained in:
Xavier Ducrohet
2009-04-29 14:38:30 -07:00
parent 8ffde4bf37
commit 70fc6e96af

View File

@@ -204,11 +204,15 @@ public class ApkBuilder extends BaseBuilder {
// get a project object
IProject project = getProject();
// list of referenced projects.
IProject[] referencedProjects = null;
try {
// Top level check to make sure the build can move forward.
abortOnBadSetup(project);
// get the list of referenced projects.
IProject[] referencedProjects = ProjectHelper.getReferencedProjects(project);
referencedProjects = ProjectHelper.getReferencedProjects(project);
IJavaProject[] referencedJavaProjects = getJavaProjects(referencedProjects);
// get the output folder, this method returns the path with a trailing
@@ -558,9 +562,31 @@ public class ApkBuilder extends BaseBuilder {
AdtPlugin.printBuildToConsole(AdtConstants.BUILD_VERBOSE, getProject(),
"Build Success!");
}
} catch (Exception exception) {
// try to catch other exception to actually display an error. This will be useful
// if we get an NPE or something so that we can at least notify the user that something
// went wrong.
// first check if this is a CoreException we threw to cancel the build.
if (exception instanceof CoreException) {
if (((CoreException)exception).getStatus().getCode() == IStatus.CANCEL) {
// Project is already marked with an error. Nothing to do
return referencedProjects;
}
}
String msg = exception.getMessage();
if (msg == null) {
msg = exception.getClass().getCanonicalName();
}
msg = String.format("Unknown error: %1$s", msg);
AdtPlugin.printErrorToConsole(project, msg);
markProject(AdtConstants.MARKER_ADT, msg, IMarker.SEVERITY_ERROR);
}
return referencedProjects;
}
@Override
protected void startupOnInitialize() {
@@ -921,7 +947,6 @@ public class ApkBuilder extends BaseBuilder {
AdtPlugin.printErrorToConsole(javaProject.getProject(), msg);
markProject(AdtConstants.MARKER_ADT, msg, IMarker.SEVERITY_ERROR);
return false;
} finally {
if (fos != null) {
try {