Browse Source

added ability to fork the JVM for those processes that call System.exit(), also added the JVM arguments

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267572 13f79535-47bb-0310-9956-ffa450edef68
master
Stefano Mazzocchi 26 years ago
parent
commit
4e7ce7833d
1 changed files with 38 additions and 7 deletions
  1. +38
    -7
      src/main/org/apache/tools/ant/taskdefs/Java.java

+ 38
- 7
src/main/org/apache/tools/ant/taskdefs/Java.java View File

@@ -64,10 +64,12 @@ import java.util.*;
*
* @author Stefano Mazzocchi <a href="mailto:stefano@pache.org">stefano@apache.org</a>
*/
public class Java extends Task {
public class Java extends Exec {

private String classname = null;
private String args = null;
private String jvmargs = null;
private boolean fork = false;
/**
* Do the execution.
@@ -75,16 +77,31 @@ public class Java extends Task {
public void execute() throws BuildException {
project.log("Calling " + classname, "java", project.MSG_VERBOSE);
if (classname == null) {
throw new BuildException("Class name must not be null.");
}

Vector argList = tokenize(args);
project.log("Java args: " + argList.toString(), "java", project.MSG_VERBOSE);
run(classname, argList);
if (fork) {
StringBuffer b = new StringBuffer();
b.append("java ");
if (jvmargs != null) {
b.append(jvmargs);
b.append(" ");
}
b.append(classname);
if (args != null) {
b.append(" ");
b.append(args);
}
run(b.toString());
} else {
Vector argList = tokenize(args);
if (jvmargs != null) project.log("JVM args ignored when same JVM is used.", "java", project.MSG_VERBOSE);
project.log("Java args: " + argList.toString(), "java", project.MSG_VERBOSE);
run(classname, argList);
}
}
/**
@@ -101,6 +118,20 @@ public class Java extends Task {
this.args = s;
}

/**
* Set the forking flag.
*/
public void setFork(String s) {
this.fork = Project.toBoolean(s);
}

/**
* Set the jvm arguments.
*/
public void setJvmargs(String s) {
this.jvmargs = s;
}
/**
* Executes the given classname with the given arguments as it
* was a command line application.


Loading…
Cancel
Save