public class Java extends Task
Modifier and Type | Field and Description |
---|---|
protected Redirector |
redirector |
protected RedirectorElement |
redirectorElement |
description, location, project
Constructor and Description |
---|
Java()
Normal constructor
|
Java(Task owner)
create a bound task
|
Modifier and Type | Method and Description |
---|---|
void |
addAssertions(Assertions asserts)
Add assertions to enable in this program (if fork=true).
|
void |
addConfiguredRedirector(RedirectorElement redirectorElement)
Add a
RedirectorElement to this task. |
void |
addEnv(Environment.Variable var)
Add an environment variable.
|
void |
addSysproperty(Environment.Variable sysp)
Add a system property.
|
void |
addSyspropertyset(PropertySet sysp)
Add a set of properties as system properties.
|
protected void |
checkConfiguration()
Check configuration.
|
void |
clearArgs()
Clear out the arguments to this java task.
|
Commandline.Argument |
createArg()
Add a command-line argument.
|
Path |
createBootclasspath()
Add a path to the bootclasspath.
|
Path |
createClasspath()
Add a path to the classpath.
|
Commandline.Argument |
createJvmarg()
Adds a JVM argument.
|
Permissions |
createPermissions()
Set the permissions for the application run inside the same JVM.
|
protected ExecuteWatchdog |
createWatchdog()
Create the Watchdog to kill a runaway process.
|
void |
execute()
Do the execution.
|
int |
executeJava()
Do the execution and return a return code.
|
protected int |
executeJava(CommandlineJava commandLine)
Execute the specified CommandlineJava.
|
CommandlineJava |
getCommandLine()
Accessor to the command line.
|
CommandlineJava.SysProperties |
getSysProperties()
Get the system properties of the command line.
|
protected void |
handleErrorFlush(java.lang.String output)
Handle output sent to System.err and flush the stream.
|
protected void |
handleErrorOutput(java.lang.String output)
Handle output sent to System.err.
|
protected void |
handleFlush(java.lang.String output)
Pass output sent to System.out to specified output file.
|
int |
handleInput(byte[] buffer,
int offset,
int length)
Handle an input request by this task.
|
protected void |
handleOutput(java.lang.String output)
Pass output sent to System.out to specified output file.
|
protected void |
maybeSetResultPropertyValue(int result)
Helper method to set result property to the
passed in value if appropriate.
|
protected void |
run(java.lang.String classname,
java.util.Vector args)
Executes the given classname with the given arguments as if it
were a command line application.
|
void |
setAppend(boolean append)
If true, append output to existing file.
|
void |
setArgs(java.lang.String s)
Deprecated: use nested arg instead.
|
void |
setClassname(java.lang.String s)
Set the Java class to execute.
|
void |
setClasspath(Path s)
Set the classpath to be used when running the Java class.
|
void |
setClasspathRef(Reference r)
Set the classpath to use by reference.
|
void |
setCloneVm(boolean cloneVm)
If set, system properties will be copied to the cloned VM--as
well as the bootclasspath unless you have explicitly specified
a bootclaspath.
|
void |
setDir(java.io.File d)
Set the working directory of the process.
|
void |
setError(java.io.File error)
Set the File to which the error stream of the process is redirected.
|
void |
setErrorProperty(java.lang.String errorProperty)
Set the property name whose value should be set to the error of
the process.
|
void |
setFailonerror(boolean fail)
If true, then fail if the command exits with a
returncode other than zero.
|
void |
setFork(boolean s)
If true, execute in a new VM.
|
void |
setInput(java.io.File input)
Set the input to use for the task.
|
void |
setInputString(java.lang.String inputString)
Set the string to use as input.
|
void |
setJar(java.io.File jarfile)
Set the location of the JAR file to execute.
|
void |
setJvm(java.lang.String s)
Set the command used to start the VM (only if forking).
|
void |
setJvmargs(java.lang.String s)
Set the command line arguments for the JVM.
|
void |
setJVMVersion(java.lang.String value)
Set the JVM version.
|
void |
setLogError(boolean logError)
Set whether error output of exec is logged.
|
void |
setMaxmemory(java.lang.String max)
Corresponds to -mx or -Xmx depending on VM version.
|
void |
setNewenvironment(boolean newenv)
If true, use a completely new environment.
|
void |
setOutput(java.io.File out)
Set the File to which the output of the process is redirected.
|
void |
setOutputproperty(java.lang.String outputProp)
Set the property name whose value should be set to the output of
the process.
|
void |
setResultProperty(java.lang.String resultProperty)
Set the name of the property in which the return code of the
command should be stored.
|
void |
setSpawn(boolean spawn)
Set whether or not you want the process to be spawned;
default is not spawned.
|
void |
setTimeout(java.lang.Long value)
Set the timeout in milliseconds after which the process will be killed.
|
protected void |
setupRedirector()
Set up properties on the redirector that we needed to store locally.
|
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
protected Redirector redirector
protected RedirectorElement redirectorElement
public Java()
public Java(Task owner)
owner
- ownerpublic void execute() throws BuildException
execute
in class Task
BuildException
- if failOnError is set to true and the application
returns a nonzero result code.public int executeJava() throws BuildException
BuildException
- if required parameters are missing.protected void checkConfiguration() throws BuildException
BuildException
- if required parameters are missing.protected int executeJava(CommandlineJava commandLine)
commandLine
- CommandLineJava instance.public void setSpawn(boolean spawn)
spawn
- if true you do not want Ant to wait for the end of the process.public void setClasspath(Path s)
s
- an Ant Path object containing the classpath.public Path createClasspath()
public Path createBootclasspath()
public Permissions createPermissions()
public void setClasspathRef(Reference r)
r
- a reference to an existing classpath.public void setJar(java.io.File jarfile) throws BuildException
jarfile
- the jarfile to execute.BuildException
- if there is also a main class specified.public void setClassname(java.lang.String s) throws BuildException
s
- the name of the main class.BuildException
- if the jar attribute has been set.public void setArgs(java.lang.String s)
s
- arguments.public void setCloneVm(boolean cloneVm)
Doesn't have any effect unless fork is true.
cloneVm
- if true copy system properties.public Commandline.Argument createArg()
public void setResultProperty(java.lang.String resultProperty)
resultProperty
- name of property.protected void maybeSetResultPropertyValue(int result)
result
- the exit codepublic void setFork(boolean s)
s
- do you want to run Java in a new VM.public void setJvmargs(java.lang.String s)
s
- jvmargs.public Commandline.Argument createJvmarg()
public void setJvm(java.lang.String s)
s
- command to start the VM.public void addSysproperty(Environment.Variable sysp)
sysp
- system property.public void addSyspropertyset(PropertySet sysp)
sysp
- set of properties to add.public void setFailonerror(boolean fail)
fail
- if true fail the build when the command exits with a
nonzero returncode.public void setDir(java.io.File d)
d
- working directory.public void setOutput(java.io.File out)
out
- the output File.public void setInput(java.io.File input)
input
- name of the input file.public void setInputString(java.lang.String inputString)
inputString
- the string which is used as the input source.public void setLogError(boolean logError)
logError
- get in the ant log the messages coming from stderr
in the case that fork = true.public void setError(java.io.File error)
error
- file getting the error stream.public void setOutputproperty(java.lang.String outputProp)
outputProp
- property name.public void setErrorProperty(java.lang.String errorProperty)
errorProperty
- property name.public void setMaxmemory(java.lang.String max)
max
- max memory parameter.public void setJVMVersion(java.lang.String value)
value
- JVM version.public void addEnv(Environment.Variable var)
Will be ignored if we are not forking a new VM.
var
- new environment variable.public void setNewenvironment(boolean newenv)
Will be ignored if we are not forking a new VM.
newenv
- if true, use a completely new environment.public void setAppend(boolean append)
append
- if true, append output to existing file.public void setTimeout(java.lang.Long value)
value
- timeout in milliseconds.public void addAssertions(Assertions asserts)
asserts
- assertion set.public void addConfiguredRedirector(RedirectorElement redirectorElement)
RedirectorElement
to this task.redirectorElement
- RedirectorElement
.protected void handleOutput(java.lang.String output)
handleOutput
in class Task
output
- a string of output on its way to the handlers.public int handleInput(byte[] buffer, int offset, int length) throws java.io.IOException
handleInput
in class Task
buffer
- the buffer into which data is to be read.offset
- the offset into the buffer at which data is stored.length
- the amount of data to read.java.io.IOException
- if the data cannot be read.protected void handleFlush(java.lang.String output)
handleFlush
in class Task
output
- string of output on its way to its handlers.protected void handleErrorOutput(java.lang.String output)
handleErrorOutput
in class Task
output
- string of stderr.protected void handleErrorFlush(java.lang.String output)
handleErrorFlush
in class Task
output
- string of stderr.protected void setupRedirector()
protected void run(java.lang.String classname, java.util.Vector args) throws BuildException
classname
- the name of the class to run.args
- arguments for the class.BuildException
- in case of IOException in the execution.public void clearArgs()
protected ExecuteWatchdog createWatchdog() throws BuildException
BuildException
- under unknown circumstances.public CommandlineJava getCommandLine()
public CommandlineJava.SysProperties getSysProperties()