|
@@ -96,6 +96,8 @@ public class Java extends Task { |
|
|
private String resultProperty; |
|
|
private String resultProperty; |
|
|
/** |
|
|
/** |
|
|
* Do the execution. |
|
|
* Do the execution. |
|
|
|
|
|
* @throws BuildException if failOnError is set to true and the application |
|
|
|
|
|
* returns a non 0 result code |
|
|
*/ |
|
|
*/ |
|
|
public void execute() throws BuildException { |
|
|
public void execute() throws BuildException { |
|
|
File savedDir = dir; |
|
|
File savedDir = dir; |
|
@@ -121,6 +123,8 @@ public class Java extends Task { |
|
|
* |
|
|
* |
|
|
* @return the return code from the execute java class if it was |
|
|
* @return the return code from the execute java class if it was |
|
|
* executed in a separate VM (fork = "yes"). |
|
|
* executed in a separate VM (fork = "yes"). |
|
|
|
|
|
* |
|
|
|
|
|
* @throws BuildException if required parameters are missing |
|
|
*/ |
|
|
*/ |
|
|
public int executeJava() throws BuildException { |
|
|
public int executeJava() throws BuildException { |
|
|
String classname = cmdl.getClassname(); |
|
|
String classname = cmdl.getClassname(); |
|
@@ -198,6 +202,8 @@ public class Java extends Task { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Adds a path to the classpath. |
|
|
* Adds a path to the classpath. |
|
|
|
|
|
* |
|
|
|
|
|
* @return created classpath |
|
|
*/ |
|
|
*/ |
|
|
public Path createClasspath() { |
|
|
public Path createClasspath() { |
|
|
return cmdl.createClasspath(getProject()).createPath(); |
|
|
return cmdl.createClasspath(getProject()).createPath(); |
|
@@ -206,6 +212,8 @@ public class Java extends Task { |
|
|
/** |
|
|
/** |
|
|
* Adds a path to the bootclasspath. |
|
|
* Adds a path to the bootclasspath. |
|
|
* @since Ant 1.6 |
|
|
* @since Ant 1.6 |
|
|
|
|
|
* |
|
|
|
|
|
* @return created bootclasspath |
|
|
*/ |
|
|
*/ |
|
|
public Path createBootclasspath() { |
|
|
public Path createBootclasspath() { |
|
|
return cmdl.createBootclasspath(getProject()).createPath(); |
|
|
return cmdl.createBootclasspath(getProject()).createPath(); |
|
@@ -213,6 +221,8 @@ public class Java extends Task { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Classpath to use, by reference. |
|
|
* Classpath to use, by reference. |
|
|
|
|
|
* |
|
|
|
|
|
* @param r a reference to an existing classpath |
|
|
*/ |
|
|
*/ |
|
|
public void setClasspathRef(Reference r) { |
|
|
public void setClasspathRef(Reference r) { |
|
|
createClasspath().setRefid(r); |
|
|
createClasspath().setRefid(r); |
|
@@ -220,6 +230,10 @@ public class Java extends Task { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* The location of the JAR file to execute. |
|
|
* The location of the JAR file to execute. |
|
|
|
|
|
* |
|
|
|
|
|
* @param jarfile the jarfile that one wants to execute |
|
|
|
|
|
* |
|
|
|
|
|
* @throws BuildException if there is also a main class specified |
|
|
*/ |
|
|
*/ |
|
|
public void setJar(File jarfile) throws BuildException { |
|
|
public void setJar(File jarfile) throws BuildException { |
|
|
if (cmdl.getClassname() != null) { |
|
|
if (cmdl.getClassname() != null) { |
|
@@ -231,6 +245,10 @@ public class Java extends Task { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Sets the Java class to execute. |
|
|
* Sets the Java class to execute. |
|
|
|
|
|
* |
|
|
|
|
|
* @param s the name of the main class |
|
|
|
|
|
* |
|
|
|
|
|
* @throws BuildException if the jar attribute has been set |
|
|
*/ |
|
|
*/ |
|
|
public void setClassname(String s) throws BuildException { |
|
|
public void setClassname(String s) throws BuildException { |
|
|
if (cmdl.getJar() != null) { |
|
|
if (cmdl.getJar() != null) { |
|
@@ -243,6 +261,9 @@ public class Java extends Task { |
|
|
/** |
|
|
/** |
|
|
* Deprecated: use nested arg instead. |
|
|
* Deprecated: use nested arg instead. |
|
|
* Set the command line arguments for the class. |
|
|
* Set the command line arguments for the class. |
|
|
|
|
|
* |
|
|
|
|
|
* @param s arguments |
|
|
|
|
|
* |
|
|
* @ant.attribute ignore="true" |
|
|
* @ant.attribute ignore="true" |
|
|
*/ |
|
|
*/ |
|
|
public void setArgs(String s) { |
|
|
public void setArgs(String s) { |
|
@@ -253,6 +274,8 @@ public class Java extends Task { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Adds a command-line argument. |
|
|
* Adds a command-line argument. |
|
|
|
|
|
* |
|
|
|
|
|
* @return created argument |
|
|
*/ |
|
|
*/ |
|
|
public Commandline.Argument createArg() { |
|
|
public Commandline.Argument createArg() { |
|
|
return cmdl.createArgument(); |
|
|
return cmdl.createArgument(); |
|
@@ -262,6 +285,8 @@ public class Java extends Task { |
|
|
* The name of a property in which the return code of the |
|
|
* The name of a property in which the return code of the |
|
|
* command should be stored. Only of interest if failonerror=false. |
|
|
* command should be stored. Only of interest if failonerror=false. |
|
|
* |
|
|
* |
|
|
|
|
|
* @param resultProperty name of property |
|
|
|
|
|
* |
|
|
* @since Ant 1.6 |
|
|
* @since Ant 1.6 |
|
|
*/ |
|
|
*/ |
|
|
public void setResultProperty(String resultProperty) { |
|
|
public void setResultProperty(String resultProperty) { |
|
@@ -271,6 +296,8 @@ public class Java extends Task { |
|
|
/** |
|
|
/** |
|
|
* helper method to set result property to the |
|
|
* helper method to set result property to the |
|
|
* passed in value if appropriate |
|
|
* passed in value if appropriate |
|
|
|
|
|
* |
|
|
|
|
|
* @param result the exit code |
|
|
*/ |
|
|
*/ |
|
|
protected void maybeSetResultPropertyValue(int result) { |
|
|
protected void maybeSetResultPropertyValue(int result) { |
|
|
String res = Integer.toString(result); |
|
|
String res = Integer.toString(result); |
|
@@ -281,6 +308,8 @@ public class Java extends Task { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* If true, execute in a new VM. |
|
|
* If true, execute in a new VM. |
|
|
|
|
|
* |
|
|
|
|
|
* @param s do you want to run Java in a new VM. |
|
|
*/ |
|
|
*/ |
|
|
public void setFork(boolean s) { |
|
|
public void setFork(boolean s) { |
|
|
this.fork = s; |
|
|
this.fork = s; |
|
@@ -288,6 +317,8 @@ public class Java extends Task { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Set the command line arguments for the JVM. |
|
|
* Set the command line arguments for the JVM. |
|
|
|
|
|
* |
|
|
|
|
|
* @param s jvmargs |
|
|
*/ |
|
|
*/ |
|
|
public void setJvmargs(String s) { |
|
|
public void setJvmargs(String s) { |
|
|
log("The jvmargs attribute is deprecated. " |
|
|
log("The jvmargs attribute is deprecated. " |
|
@@ -297,6 +328,8 @@ public class Java extends Task { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Adds a JVM argument. |
|
|
* Adds a JVM argument. |
|
|
|
|
|
* |
|
|
|
|
|
* @return JVM argument created |
|
|
*/ |
|
|
*/ |
|
|
public Commandline.Argument createJvmarg() { |
|
|
public Commandline.Argument createJvmarg() { |
|
|
return cmdl.createVmArgument(); |
|
|
return cmdl.createVmArgument(); |
|
@@ -304,6 +337,8 @@ public class Java extends Task { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Set the command used to start the VM (only if not forking). |
|
|
* Set the command used to start the VM (only if not forking). |
|
|
|
|
|
* |
|
|
|
|
|
* @param s command to start the VM |
|
|
*/ |
|
|
*/ |
|
|
public void setJvm(String s) { |
|
|
public void setJvm(String s) { |
|
|
cmdl.setVm(s); |
|
|
cmdl.setVm(s); |
|
@@ -311,6 +346,8 @@ public class Java extends Task { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Adds a system property. |
|
|
* Adds a system property. |
|
|
|
|
|
* |
|
|
|
|
|
* @param sysp system property |
|
|
*/ |
|
|
*/ |
|
|
public void addSysproperty(Environment.Variable sysp) { |
|
|
public void addSysproperty(Environment.Variable sysp) { |
|
|
cmdl.addSysproperty(sysp); |
|
|
cmdl.addSysproperty(sysp); |
|
@@ -319,6 +356,8 @@ public class Java extends Task { |
|
|
/** |
|
|
/** |
|
|
* Adds a set of properties as system properties. |
|
|
* Adds a set of properties as system properties. |
|
|
* |
|
|
* |
|
|
|
|
|
* @param sysp set of properties to add |
|
|
|
|
|
* |
|
|
* @since Ant 1.6 |
|
|
* @since Ant 1.6 |
|
|
*/ |
|
|
*/ |
|
|
public void addSyspropertyset(PropertySet sysp) { |
|
|
public void addSyspropertyset(PropertySet sysp) { |
|
@@ -328,6 +367,9 @@ public class Java extends Task { |
|
|
/** |
|
|
/** |
|
|
* If true, then fail if the command exits with a |
|
|
* If true, then fail if the command exits with a |
|
|
* returncode other than 0 |
|
|
* returncode other than 0 |
|
|
|
|
|
* |
|
|
|
|
|
* @param fail if true fail the build when the command exits with a non |
|
|
|
|
|
* zero returncode |
|
|
*/ |
|
|
*/ |
|
|
public void setFailonerror(boolean fail) { |
|
|
public void setFailonerror(boolean fail) { |
|
|
failOnError = fail; |
|
|
failOnError = fail; |
|
@@ -335,6 +377,9 @@ public class Java extends Task { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* The working directory of the process |
|
|
* The working directory of the process |
|
|
|
|
|
* |
|
|
|
|
|
* @param d working directory |
|
|
|
|
|
* |
|
|
*/ |
|
|
*/ |
|
|
public void setDir(File d) { |
|
|
public void setDir(File d) { |
|
|
this.dir = d; |
|
|
this.dir = d; |
|
@@ -342,6 +387,8 @@ public class Java extends Task { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* File the output of the process is redirected to. |
|
|
* File the output of the process is redirected to. |
|
|
|
|
|
* |
|
|
|
|
|
* @param out name of the output file |
|
|
*/ |
|
|
*/ |
|
|
public void setOutput(File out) { |
|
|
public void setOutput(File out) { |
|
|
redirector.setOutput(out); |
|
|
redirector.setOutput(out); |
|
@@ -349,6 +396,8 @@ public class Java extends Task { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Set the input to use for the task |
|
|
* Set the input to use for the task |
|
|
|
|
|
* |
|
|
|
|
|
* @param input name of the input file |
|
|
*/ |
|
|
*/ |
|
|
public void setInput(File input) { |
|
|
public void setInput(File input) { |
|
|
redirector.setInput(input); |
|
|
redirector.setInput(input); |
|
@@ -367,6 +416,9 @@ public class Java extends Task { |
|
|
* Controls whether error output of exec is logged. This is only useful |
|
|
* Controls whether error output of exec is logged. This is only useful |
|
|
* when output is being redirected and error output is desired in the |
|
|
* when output is being redirected and error output is desired in the |
|
|
* Ant log |
|
|
* Ant log |
|
|
|
|
|
* |
|
|
|
|
|
* @param logError get in the ant log the messages coming from stderr |
|
|
|
|
|
* in the case that fork = true |
|
|
*/ |
|
|
*/ |
|
|
public void setLogError(boolean logError) { |
|
|
public void setLogError(boolean logError) { |
|
|
redirector.setLogError(logError); |
|
|
redirector.setLogError(logError); |
|
@@ -375,6 +427,8 @@ public class Java extends Task { |
|
|
/** |
|
|
/** |
|
|
* File the error stream of the process is redirected to. |
|
|
* File the error stream of the process is redirected to. |
|
|
* |
|
|
* |
|
|
|
|
|
* @param error file getting the error stream |
|
|
|
|
|
* |
|
|
* @since ant 1.6 |
|
|
* @since ant 1.6 |
|
|
*/ |
|
|
*/ |
|
|
public void setError(File error) { |
|
|
public void setError(File error) { |
|
@@ -384,6 +438,9 @@ public class Java extends Task { |
|
|
/** |
|
|
/** |
|
|
* Property name whose value should be set to the output of |
|
|
* Property name whose value should be set to the output of |
|
|
* the process. |
|
|
* the process. |
|
|
|
|
|
* |
|
|
|
|
|
* @param outputProp property name |
|
|
|
|
|
* |
|
|
*/ |
|
|
*/ |
|
|
public void setOutputproperty(String outputProp) { |
|
|
public void setOutputproperty(String outputProp) { |
|
|
redirector.setOutputProperty(outputProp); |
|
|
redirector.setOutputProperty(outputProp); |
|
@@ -393,6 +450,8 @@ public class Java extends Task { |
|
|
* Property name whose value should be set to the error of |
|
|
* Property name whose value should be set to the error of |
|
|
* the process. |
|
|
* the process. |
|
|
* |
|
|
* |
|
|
|
|
|
* @param errorProperty property name |
|
|
|
|
|
* |
|
|
* @since ant 1.6 |
|
|
* @since ant 1.6 |
|
|
*/ |
|
|
*/ |
|
|
public void setErrorProperty(String errorProperty) { |
|
|
public void setErrorProperty(String errorProperty) { |
|
@@ -401,6 +460,8 @@ public class Java extends Task { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Corresponds to -mx or -Xmx depending on VM version. |
|
|
* Corresponds to -mx or -Xmx depending on VM version. |
|
|
|
|
|
* |
|
|
|
|
|
* @param max max memory parameter |
|
|
*/ |
|
|
*/ |
|
|
public void setMaxmemory(String max) { |
|
|
public void setMaxmemory(String max) { |
|
|
cmdl.setMaxmemory(max); |
|
|
cmdl.setMaxmemory(max); |
|
@@ -419,6 +480,8 @@ public class Java extends Task { |
|
|
* |
|
|
* |
|
|
* <p>Will be ignored if we are not forking a new VM. |
|
|
* <p>Will be ignored if we are not forking a new VM. |
|
|
* |
|
|
* |
|
|
|
|
|
* @param var new environment variable |
|
|
|
|
|
* |
|
|
* @since Ant 1.5 |
|
|
* @since Ant 1.5 |
|
|
*/ |
|
|
*/ |
|
|
public void addEnv(Environment.Variable var) { |
|
|
public void addEnv(Environment.Variable var) { |
|
@@ -430,6 +493,8 @@ public class Java extends Task { |
|
|
* |
|
|
* |
|
|
* <p>Will be ignored if we are not forking a new VM. |
|
|
* <p>Will be ignored if we are not forking a new VM. |
|
|
* |
|
|
* |
|
|
|
|
|
* @param newenv if true, use a completely new environment. |
|
|
|
|
|
* |
|
|
* @since Ant 1.5 |
|
|
* @since Ant 1.5 |
|
|
*/ |
|
|
*/ |
|
|
public void setNewenvironment(boolean newenv) { |
|
|
public void setNewenvironment(boolean newenv) { |
|
@@ -439,6 +504,8 @@ public class Java extends Task { |
|
|
/** |
|
|
/** |
|
|
* If true, append output to existing file. |
|
|
* If true, append output to existing file. |
|
|
* |
|
|
* |
|
|
|
|
|
* @param append if true, append output to existing file |
|
|
|
|
|
* |
|
|
* @since Ant 1.5 |
|
|
* @since Ant 1.5 |
|
|
*/ |
|
|
*/ |
|
|
public void setAppend(boolean append) { |
|
|
public void setAppend(boolean append) { |
|
@@ -448,6 +515,8 @@ public class Java extends Task { |
|
|
/** |
|
|
/** |
|
|
* Timeout in milliseconds after which the process will be killed. |
|
|
* Timeout in milliseconds after which the process will be killed. |
|
|
* |
|
|
* |
|
|
|
|
|
* @param value time out in milliseconds |
|
|
|
|
|
* |
|
|
* @since Ant 1.5 |
|
|
* @since Ant 1.5 |
|
|
*/ |
|
|
*/ |
|
|
public void setTimeout(Long value) { |
|
|
public void setTimeout(Long value) { |
|
@@ -457,6 +526,8 @@ public class Java extends Task { |
|
|
/** |
|
|
/** |
|
|
* Pass output sent to System.out to specified output file. |
|
|
* Pass output sent to System.out to specified output file. |
|
|
* |
|
|
* |
|
|
|
|
|
* @param output a string of output on its way to the handlers |
|
|
|
|
|
* |
|
|
* @since Ant 1.5 |
|
|
* @since Ant 1.5 |
|
|
*/ |
|
|
*/ |
|
|
protected void handleOutput(String output) { |
|
|
protected void handleOutput(String output) { |
|
@@ -467,6 +538,18 @@ public class Java extends Task { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Handle an input request by this task |
|
|
|
|
|
* |
|
|
|
|
|
* @param buffer the buffer into which data is to be read. |
|
|
|
|
|
* @param offset the offset into the buffer at which data is stored. |
|
|
|
|
|
* @param length the amount of data to read |
|
|
|
|
|
* |
|
|
|
|
|
* @return the number of bytes read |
|
|
|
|
|
* |
|
|
|
|
|
* @exception IOException if the data cannot be read |
|
|
|
|
|
* @since Ant 1.6 |
|
|
|
|
|
*/ |
|
|
public int handleInput(byte[] buffer, int offset, int length) |
|
|
public int handleInput(byte[] buffer, int offset, int length) |
|
|
throws IOException { |
|
|
throws IOException { |
|
|
if (redirector.getInputStream() != null) { |
|
|
if (redirector.getInputStream() != null) { |
|
@@ -479,6 +562,8 @@ public class Java extends Task { |
|
|
/** |
|
|
/** |
|
|
* Pass output sent to System.out to specified output file. |
|
|
* Pass output sent to System.out to specified output file. |
|
|
* |
|
|
* |
|
|
|
|
|
* @param output string of output on its way to its handlers |
|
|
|
|
|
* |
|
|
* @since Ant 1.5.2 |
|
|
* @since Ant 1.5.2 |
|
|
*/ |
|
|
*/ |
|
|
protected void handleFlush(String output) { |
|
|
protected void handleFlush(String output) { |
|
@@ -492,6 +577,8 @@ public class Java extends Task { |
|
|
/** |
|
|
/** |
|
|
* Pass output sent to System.err to specified output file. |
|
|
* Pass output sent to System.err to specified output file. |
|
|
* |
|
|
* |
|
|
|
|
|
* @param output string of stderr |
|
|
|
|
|
* |
|
|
* @since Ant 1.5 |
|
|
* @since Ant 1.5 |
|
|
*/ |
|
|
*/ |
|
|
protected void handleErrorOutput(String output) { |
|
|
protected void handleErrorOutput(String output) { |
|
@@ -505,6 +592,8 @@ public class Java extends Task { |
|
|
/** |
|
|
/** |
|
|
* Pass output sent to System.err to specified output file. |
|
|
* Pass output sent to System.err to specified output file. |
|
|
* |
|
|
* |
|
|
|
|
|
* @param output string of stderr |
|
|
|
|
|
* |
|
|
* @since Ant 1.5.2 |
|
|
* @since Ant 1.5.2 |
|
|
*/ |
|
|
*/ |
|
|
protected void handleErrorFlush(String output) { |
|
|
protected void handleErrorFlush(String output) { |
|
@@ -579,6 +668,10 @@ public class Java extends Task { |
|
|
/** |
|
|
/** |
|
|
* Executes the given classname with the given arguments as it |
|
|
* Executes the given classname with the given arguments as it |
|
|
* was a command line application. |
|
|
* was a command line application. |
|
|
|
|
|
* |
|
|
|
|
|
* @param classname the name of the class to run |
|
|
|
|
|
* @param args arguments for the class |
|
|
|
|
|
* @throws BuildException in case of IO Exception in the execution |
|
|
*/ |
|
|
*/ |
|
|
protected void run(String classname, Vector args) throws BuildException { |
|
|
protected void run(String classname, Vector args) throws BuildException { |
|
|
CommandlineJava cmdj = new CommandlineJava(); |
|
|
CommandlineJava cmdj = new CommandlineJava(); |
|
@@ -599,6 +692,10 @@ public class Java extends Task { |
|
|
/** |
|
|
/** |
|
|
* Create the Watchdog to kill a runaway process. |
|
|
* Create the Watchdog to kill a runaway process. |
|
|
* |
|
|
* |
|
|
|
|
|
* @return new watchdog |
|
|
|
|
|
* |
|
|
|
|
|
* @throws BuildException under unknown circumnstances |
|
|
|
|
|
* |
|
|
* @since Ant 1.5 |
|
|
* @since Ant 1.5 |
|
|
*/ |
|
|
*/ |
|
|
protected ExecuteWatchdog createWatchdog() throws BuildException { |
|
|
protected ExecuteWatchdog createWatchdog() throws BuildException { |
|
|