Browse Source

Don't print the message of a thrown BuildException to stderr twice.

Submitted by:	Diane Holt <holtdl@yahoo.com>,
                Nico Seessle <Nico.Seessle@epost.de>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268090 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 24 years ago
parent
commit
b02f11df78
1 changed files with 26 additions and 6 deletions
  1. +26
    -6
      src/main/org/apache/tools/ant/Main.java

+ 26
- 6
src/main/org/apache/tools/ant/Main.java View File

@@ -118,6 +118,16 @@ public class Main {
*/ */
private boolean projectHelp = false; private boolean projectHelp = false;


/**
* Prints the message of the Throwable if it's not null.
*/
private static void printMessage(Throwable t) {
String message = t.getMessage();
if (message != null) {
System.err.println(message);
}
}

/** /**
* Command line entry point. This method kicks off the building * Command line entry point. This method kicks off the building
* of a project object and executes a build using either a given * of a project object and executes a build using either a given
@@ -126,16 +136,26 @@ public class Main {
* @param args Command line args. * @param args Command line args.
*/ */
public static void main(String[] args) { public static void main(String[] args) {
Main m = null;

try { try {
new Main(args).runBuild();
System.exit(0);
m = new Main(args);
} catch(Throwable exc) {
printMessage(exc);
System.exit(1);
} }
catch(Throwable exc) {
String message = exc.getMessage();
if (message != null) {
System.err.println(message);

try {
m.runBuild();
System.exit(0);
} catch (BuildException be) {
if (m.err != System.err) {
printMessage(be);
} }
System.exit(1); System.exit(1);
} catch(Throwable exc) {
printMessage(exc);
System.exit(1);
} }
} }




Loading…
Cancel
Save