Browse Source

change error code of the launcher. We could change it from 2, its now in a constant where we can tune it.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@433793 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 19 years ago
parent
commit
7bf41207e0
2 changed files with 13 additions and 10 deletions
  1. +1
    -1
      WHATSNEW
  2. +12
    -9
      src/main/org/apache/tools/ant/launch/Launcher.java

+ 1
- 1
WHATSNEW View File

@@ -94,7 +94,7 @@ Changes that could break older environments:
* <scp> now optionally supports the sftp protocol, you may need a newer jsch.jar. * <scp> now optionally supports the sftp protocol, you may need a newer jsch.jar.
Bugzilla Report 39373. Bugzilla Report 39373.


* Ant launcher program prints errors to stderr, and exits with a -1 exit code
* Ant launcher program prints errors to stderr, and exits with a 2 exit code
value if, for any reason, it cannot actually start Ant proper. This will only value if, for any reason, it cannot actually start Ant proper. This will only
affect programs/scripts that called the launcher and which did not want to affect programs/scripts that called the launcher and which did not want to
receive an error if ant itself would not start receive an error if ant itself would not start


+ 12
- 9
src/main/org/apache/tools/ant/launch/Launcher.java View File

@@ -19,7 +19,6 @@ package org.apache.tools.ant.launch;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.io.UnsupportedEncodingException;
import java.io.File; import java.io.File;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.List; import java.util.List;
@@ -89,6 +88,11 @@ public class Launcher {
*/ */
private static final String JAVA_CLASS_PATH = "java.class.path"; private static final String JAVA_CLASS_PATH = "java.class.path";


/**
* Exit code on trouble
*/
protected static final int EXIT_CODE_ERROR = 2;

/** /**
* Entry point for starting command line Ant. * Entry point for starting command line Ant.
* *
@@ -98,21 +102,20 @@ public class Launcher {
int exitCode; int exitCode;
try { try {
Launcher launcher = new Launcher(); Launcher launcher = new Launcher();
exitCode=launcher.run(args);
exitCode = launcher.run(args);
} catch (LaunchException e) { } catch (LaunchException e) {
exitCode=-1;
exitCode = EXIT_CODE_ERROR;
System.err.println(e.getMessage()); System.err.println(e.getMessage());
} catch (Throwable t) { } catch (Throwable t) {
exitCode=-1;
exitCode = EXIT_CODE_ERROR;
t.printStackTrace(System.err); t.printStackTrace(System.err);
} }
if(exitCode!=0) {
if (exitCode != 0) {
System.exit(exitCode); System.exit(exitCode);
} }
} }



/** /**
* Add a CLASSPATH or -lib to lib path urls. * Add a CLASSPATH or -lib to lib path urls.
* *
@@ -300,10 +303,10 @@ public class Launcher {
File mainJar = Locator.getClassSource(mainClass); File mainJar = Locator.getClassSource(mainClass);
System.err.println( System.err.println(
"Location of this class " + mainJar); "Location of this class " + mainJar);
exitCode=-1;
exitCode = EXIT_CODE_ERROR;
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(System.err); t.printStackTrace(System.err);
exitCode=-1;
exitCode = EXIT_CODE_ERROR;
} }
return exitCode; return exitCode;


Loading…
Cancel
Save