Browse Source

refactoring to ease extension

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@550573 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 18 years ago
parent
commit
6872650389
1 changed files with 19 additions and 3 deletions
  1. +19
    -3
      src/main/org/apache/tools/ant/taskdefs/Java.java

+ 19
- 3
src/main/org/apache/tools/ant/taskdefs/Java.java View File

@@ -101,6 +101,7 @@ public class Java extends Task {

int err = -1;
try {
checkConfiguration();
err = executeJava();
if (err != 0) {
if (failOnError) {
@@ -128,6 +129,14 @@ public class Java extends Task {
* @throws BuildException if required parameters are missing.
*/
public int executeJava() throws BuildException {
return executeJava(getCommandLine());
}

/**
* Check configuration.
* @throws BuildException if required parameters are missing.
*/
protected void checkConfiguration() throws BuildException {
String classname = getCommandLine().getClassname();
if (classname == null && getCommandLine().getJar() == null) {
throw new BuildException("Classname must not be null.");
@@ -188,17 +197,24 @@ public class Java extends Task {
Project.MSG_VERBOSE);
}
setupRedirector();
}

/**
* Execute the specified CommandlineJava.
* @param commandLine CommandLineJava instance.
*/
protected int executeJava(CommandlineJava commandLine) {
try {
if (fork) {
if (!spawn) {
return fork(getCommandLine().getCommandline());
return fork(commandLine.getCommandline());
} else {
spawn(getCommandLine().getCommandline());
spawn(commandLine.getCommandline());
return 0;
}
} else {
try {
run(getCommandLine());
run(commandLine);
return 0;
} catch (ExitException ex) {
return ex.getStatus();


Loading…
Cancel
Save