Modifier and Type | Field and Description |
---|---|
protected Redirector |
redirector |
protected RedirectorElement |
redirectorElement |
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.
|
Path |
createModulepath()
Add a path to the modulepath.
|
Permissions |
createPermissions()
Set the permissions for the application run inside the same JVM.
|
Path |
createUpgrademodulepath()
Add a path to the upgrademodulepath.
|
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(String output)
Handle output sent to System.err and flush the stream.
|
protected void |
handleErrorOutput(String output)
Handle output sent to System.err.
|
protected void |
handleFlush(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(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(String classname,
Vector<String> 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(String s)
Deprecated: use nested arg instead.
|
void |
setClassname(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 bootclasspath.
|
void |
setDir(File d)
Set the working directory of the process.
|
void |
setError(File error)
Set the File to which the error stream of the process is redirected.
|
void |
setErrorProperty(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(File input)
Set the input to use for the task.
|
void |
setInputString(String inputString)
Set the string to use as input.
|
void |
setJar(File jarfile)
Set the location of the JAR file to execute.
|
void |
setJvm(String s)
Set the command used to start the VM (only if forking).
|
void |
setJvmargs(String s)
Set the command line arguments for the JVM.
|
void |
setJVMVersion(String value)
Set the JVM version.
|
void |
setLogError(boolean logError)
Set whether error output of exec is logged.
|
void |
setMaxmemory(String max)
Corresponds to -mx or -Xmx depending on VM version.
|
void |
setModule(String module)
Set the Java module to execute.
|
void |
setModulepath(Path mp)
Set the modulepath to be used when running the Java class.
|
void |
setModulepathRef(Reference r)
Set the modulepath to use by reference.
|
void |
setNewenvironment(boolean newenv)
If true, use a completely new environment.
|
void |
setOutput(File out)
Set the File to which the output of the process is redirected.
|
void |
setOutputproperty(String outputProp)
Set the property name whose value should be set to the output of
the process.
|
void |
setResultProperty(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(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 addAssertions(Assertions asserts)
asserts
- assertion set.public void addConfiguredRedirector(RedirectorElement redirectorElement)
RedirectorElement
to this task.redirectorElement
- RedirectorElement
.public void addEnv(Environment.Variable var)
Will be ignored if we are not forking a new VM.
var
- new environment variable.public void addSysproperty(Environment.Variable sysp)
sysp
- system property.public void addSyspropertyset(PropertySet sysp)
sysp
- set of properties to add.protected void checkConfiguration() throws BuildException
BuildException
- if required parameters are missing.public void clearArgs()
public Commandline.Argument createArg()
public Path createBootclasspath()
public Path createClasspath()
public Commandline.Argument createJvmarg()
public Path createModulepath()
public Permissions createPermissions()
public Path createUpgrademodulepath()
protected ExecuteWatchdog createWatchdog() throws BuildException
BuildException
- under unknown circumstances.public 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 int executeJava(CommandlineJava commandLine)
commandLine
- CommandLineJava instance.public CommandlineJava getCommandLine()
public CommandlineJava.SysProperties getSysProperties()
protected void handleErrorFlush(String output)
handleErrorFlush
in class Task
output
- string of stderr.protected void handleErrorOutput(String output)
handleErrorOutput
in class Task
output
- string of stderr.protected void handleFlush(String output)
handleFlush
in class Task
output
- string of output on its way to its handlers.public int handleInput(byte[] buffer, int offset, int length) throws 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.IOException
- if the data cannot be read.protected void handleOutput(String output)
handleOutput
in class Task
output
- a string of output on its way to the handlers.protected void maybeSetResultPropertyValue(int result)
result
- the exit codeprotected void run(String classname, Vector<String> 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 setAppend(boolean append)
append
- if true, append output to existing file.public void setArgs(String s)
s
- arguments.public void setClassname(String s) throws BuildException
s
- the name of the main class.BuildException
- if the jar attribute has been set.public void setClasspath(Path s)
s
- an Ant Path object containing the classpath.public void setClasspathRef(Reference r)
r
- a reference to an existing classpath.public void setCloneVm(boolean cloneVm)
Doesn't have any effect unless fork is true.
cloneVm
- if true copy system properties.public void setDir(File d)
d
- working directory.public void setError(File error)
error
- file getting the error stream.public void setErrorProperty(String errorProperty)
errorProperty
- property name.public void setFailonerror(boolean fail)
fail
- if true fail the build when the command exits with a
nonzero returncode.public void setFork(boolean s)
s
- do you want to run Java in a new VM.public void setInput(File input)
input
- name of the input file.public void setInputString(String inputString)
inputString
- the string which is used as the input source.public void setJar(File jarfile) throws BuildException
jarfile
- the jarfile to execute.BuildException
- if there is also a main class specified.public void setJvm(String s)
s
- command to start the VM.public void setJvmargs(String s)
s
- jvmargs.public void setJVMVersion(String value)
value
- JVM version.public void setLogError(boolean logError)
logError
- get in the ant log the messages coming from stderr
in the case that fork = true.public void setMaxmemory(String max)
max
- max memory parameter.public void setModule(String module) throws BuildException
module
- the name of the module.BuildException
- if the jar attribute has been set.public void setModulepath(Path mp)
mp
- an Ant Path object containing the modulepath.public void setModulepathRef(Reference r)
r
- a reference to an existing modulepath.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 setOutput(File out)
out
- the output File.public void setOutputproperty(String outputProp)
outputProp
- property name.public void setResultProperty(String resultProperty)
resultProperty
- name of property.public void setSpawn(boolean spawn)
spawn
- if true you do not want Ant to wait for the end of the process.public void setTimeout(Long value)
value
- timeout in milliseconds.protected void setupRedirector()