Modifier and Type | Field and Description |
---|---|
protected Commandline |
cmdl |
protected boolean |
failOnError |
protected boolean |
newEnvironment |
protected Redirector |
redirector |
protected RedirectorElement |
redirectorElement |
description, location, project
Constructor and Description |
---|
ExecTask()
Create an instance.
|
ExecTask(Task owner)
create an instance that is helping another task.
|
Modifier and Type | Method and Description |
---|---|
void |
addConfiguredRedirector(RedirectorElement redirectorElement)
Add a
RedirectorElement to this task. |
void |
addEnv(Environment.Variable var)
Add an environment variable to the launched process.
|
protected void |
checkConfiguration()
Has the user set all necessary attributes?
|
Commandline.Argument |
createArg()
Adds a command-line argument.
|
protected ExecuteStreamHandler |
createHandler()
Create the StreamHandler to use with our Execute instance.
|
protected ExecuteWatchdog |
createWatchdog()
Create the Watchdog to kill a runaway process.
|
void |
execute()
Do the work.
|
java.lang.String |
getOs()
List of operating systems on which the command may be executed.
|
java.lang.String |
getOsFamily()
Restrict this execution to a single OS Family
|
boolean |
getResolveExecutable()
Indicates whether to attempt to resolve the executable to a
file.
|
protected boolean |
isValidOs()
Is this the OS the user wanted?
|
protected void |
logFlush()
Flush the output stream - if there is one.
|
protected void |
maybeSetResultPropertyValue(int result)
Helper method to set result property to the
passed in value if appropriate.
|
protected Execute |
prepareExec()
Create an Execute instance with the correct working directory set.
|
protected java.lang.String |
resolveExecutable(java.lang.String exec,
boolean mustSearchPath)
The method attempts to figure out where the executable is so that we can feed
the full path.
|
protected void |
runExec(Execute exe)
Run the command using the given Execute instance.
|
protected void |
runExecute(Execute exe)
A Utility method for this classes and subclasses to run an
Execute instance (an external command).
|
void |
setAppend(boolean append)
Set whether output should be appended to or overwrite an existing file.
|
void |
setCommand(Commandline cmdl)
Sets a command line.
|
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 should be redirected.
|
void |
setErrorProperty(java.lang.String errorProperty)
Sets the name of the property whose value should be set to the error of
the process.
|
void |
setExecutable(java.lang.String value)
Set the name of the executable program.
|
void |
setFailIfExecutionFails(boolean flag)
Set whether to stop the build if program cannot be started.
|
void |
setFailonerror(boolean fail)
Fail if the command exits with a non-zero return code.
|
void |
setInput(java.io.File input)
Set the input file to use for the task.
|
void |
setInputString(java.lang.String inputString)
Set the string to use as input.
|
void |
setLogError(boolean logError)
Controls whether error output of exec is logged.
|
void |
setNewenvironment(boolean newenv)
Do not propagate old environment when new environment variables are specified.
|
void |
setOs(java.lang.String os)
List of operating systems on which the command may be executed.
|
void |
setOsFamily(java.lang.String osFamily)
Restrict this execution to a single OS Family
|
void |
setOutput(java.io.File out)
File the output of the process is redirected to.
|
void |
setOutputproperty(java.lang.String outputProp)
Sets the property name whose value should be set to the output of
the process.
|
void |
setResolveExecutable(boolean resolveExecutable)
Set whether to attempt to resolve the executable to a file.
|
void |
setResultProperty(java.lang.String resultProperty)
Sets the name of a property in which the return code of the
command should be stored.
|
void |
setSearchPath(boolean searchPath)
Set whether to search nested, then
system PATH environment variables for the executable.
|
void |
setSpawn(boolean spawn)
Set whether or not you want the process to be spawned.
|
void |
setTimeout(java.lang.Integer value)
Set the timeout in milliseconds after which the process will be killed.
|
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.
|
void |
setVMLauncher(boolean vmLauncher)
Set whether to launch new process with VM, otherwise use the OS's shell.
|
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
protected boolean failOnError
protected boolean newEnvironment
protected Commandline cmdl
protected Redirector redirector
protected RedirectorElement redirectorElement
public ExecTask()
public ExecTask(Task owner)
owner
- task that we belong topublic void setSpawn(boolean spawn)
spawn
- if true you do not want Ant to wait for the end of the process.public void setTimeout(java.lang.Long value)
value
- timeout in milliseconds.public void setTimeout(java.lang.Integer value)
value
- timeout in milliseconds.public void setExecutable(java.lang.String value)
value
- the name of the executable program.public void setDir(java.io.File d)
d
- the working directory of the process.public void setOs(java.lang.String os)
os
- list of operating systems on which the command may be executed.public final java.lang.String getOs()
public void setCommand(Commandline cmdl)
cmdl
- command line.public void setOutput(java.io.File out)
out
- name of a file to which output should be sent.public void setInput(java.io.File input)
input
- name of a file from which to get input.public void setInputString(java.lang.String inputString)
inputString
- the string which is used as the input source.public void setLogError(boolean logError)
logError
- set to true to log error output in the normal ant log.public void setError(java.io.File error)
error
- a file to which stderr should be sent.public void setOutputproperty(java.lang.String outputProp)
outputProp
- name of property.public void setErrorProperty(java.lang.String errorProperty)
errorProperty
- name of property.public void setFailonerror(boolean fail)
fail
- if true fail the command on non-zero return code.public void setNewenvironment(boolean newenv)
newenv
- if true, do not propagate old environment
when new environment variables are specified.public void setResolveExecutable(boolean resolveExecutable)
resolveExecutable
- if true, attempt to resolve the
path of the executable.public void setSearchPath(boolean searchPath)
searchPath
- if true, search PATHs.public boolean getResolveExecutable()
public void addEnv(Environment.Variable var)
var
- new environment variable.public Commandline.Argument createArg()
public void setResultProperty(java.lang.String resultProperty)
resultProperty
- name of property.protected void maybeSetResultPropertyValue(int result)
result
- value desired for the result property value.public void setFailIfExecutionFails(boolean flag)
flag
- stop the build if program cannot be started.public void setAppend(boolean append)
append
- if true append is desired.public void addConfiguredRedirector(RedirectorElement redirectorElement)
RedirectorElement
to this task.redirectorElement
- RedirectorElement
.public void setOsFamily(java.lang.String osFamily)
osFamily
- the family to restrict to.public final java.lang.String getOsFamily()
protected java.lang.String resolveExecutable(java.lang.String exec, boolean mustSearchPath)
exec
- the name of the executable.mustSearchPath
- if true, the executable will be looked up in
the PATH environment and the absolute path is returned.public void execute() throws BuildException
execute
in class Task
BuildException
- in a number of circumstances:
protected void checkConfiguration() throws BuildException
BuildException
- if there are missing required parameters.protected void setupRedirector()
protected boolean isValidOs()
true
if the os and osfamily attributes are null.true
if osfamily is set, and the os family and must match
that of the current OS, according to the logic of
Os.isOs(String, String, String, String)
, and the result of the
os
attribute must also evaluate true.
true
if os is set, and the system.property os.name
is found in the os attribute,false
otherwise.public void setVMLauncher(boolean vmLauncher)
vmLauncher
- true if we want to launch new process with VM,
false if we want to use the OS's shell.protected Execute prepareExec() throws BuildException
BuildException
- under unknown circumstances.protected final void runExecute(Execute exe) throws java.io.IOException
exe
- instance of the execute class.java.io.IOException
- in case of problem to attach to the stdin/stdout/stderr
streams of the process.protected void runExec(Execute exe) throws BuildException
exe
- instance of Execute to run.BuildException
- if the new process could not be started
only if failIfExecFails is set to true (the default).protected ExecuteStreamHandler createHandler() throws BuildException
BuildException
- under unknown circumstances.protected ExecuteWatchdog createWatchdog() throws BuildException
BuildException
- under unknown circumstances.protected void logFlush()