Modifier and Type | Field and Description |
---|---|
protected Commandline |
cmdl |
protected boolean |
failOnError |
protected boolean |
newEnvironment |
protected Redirector |
redirector |
protected RedirectorElement |
redirectorElement |
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.
|
String |
getOs()
List of operating systems on which the command may be executed.
|
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 String |
resolveExecutable(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(File d)
Set the working directory of the process.
|
void |
setError(File error)
Set the File to which the error stream of the process should be redirected.
|
void |
setErrorProperty(String errorProperty)
Sets the name of the property whose value should be set to the error of
the process.
|
void |
setExecutable(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(File input)
Set the input file to use for the task.
|
void |
setInputString(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(String os)
List of operating systems on which the command may be executed.
|
void |
setOsFamily(String osFamily)
Restrict this execution to a single OS Family
|
void |
setOutput(File out)
File the output of the process is redirected to.
|
void |
setOutputproperty(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(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(Integer value)
Set the timeout in milliseconds after which the process will be killed.
|
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.
|
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 Commandline cmdl
protected boolean failOnError
protected boolean newEnvironment
protected Redirector redirector
protected RedirectorElement redirectorElement
public ExecTask()
public ExecTask(Task owner)
owner
- task that we belong topublic void addConfiguredRedirector(RedirectorElement redirectorElement)
RedirectorElement
to this task.redirectorElement
- RedirectorElement
.public void addEnv(Environment.Variable var)
var
- new environment variable.protected void checkConfiguration() throws BuildException
BuildException
- if there are missing required parameters.public Commandline.Argument createArg()
protected ExecuteStreamHandler createHandler() throws BuildException
BuildException
- under unknown circumstances.protected ExecuteWatchdog createWatchdog() throws BuildException
BuildException
- under unknown circumstances.public void execute() throws BuildException
execute
in class Task
BuildException
- in a number of circumstances:
public final String getOs()
public final String getOsFamily()
public boolean getResolveExecutable()
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.protected void logFlush()
protected void maybeSetResultPropertyValue(int result)
result
- value desired for the result property value.protected Execute prepareExec() throws BuildException
BuildException
- under unknown circumstances.protected String resolveExecutable(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.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 final void runExecute(Execute exe) throws IOException
exe
- instance of the execute class.IOException
- in case of problem to attach to the stdin/stdout/stderr
streams of the process.public void setAppend(boolean append)
append
- if true append is desired.public void setCommand(Commandline cmdl)
cmdl
- command line.public void setDir(File d)
d
- the working directory of the process.public void setError(File error)
error
- a file to which stderr should be sent.public void setErrorProperty(String errorProperty)
errorProperty
- name of property.public void setExecutable(String value)
value
- the name of the executable program.public void setFailIfExecutionFails(boolean flag)
flag
- stop the build if program cannot be started.public void setFailonerror(boolean fail)
fail
- if true fail the command on non-zero return code.public void setInput(File input)
input
- name of a file from which to get input.public void setInputString(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 setNewenvironment(boolean newenv)
newenv
- if true, do not propagate old environment
when new environment variables are specified.public void setOs(String os)
os
- list of operating systems on which the command may be executed.public void setOsFamily(String osFamily)
osFamily
- the family to restrict to.public void setOutput(File out)
out
- name of a file to which output should be sent.public void setOutputproperty(String outputProp)
outputProp
- name of property.public void setResolveExecutable(boolean resolveExecutable)
resolveExecutable
- if true, attempt to resolve the
path of the executable.public void setResultProperty(String resultProperty)
resultProperty
- name of property.public void setSearchPath(boolean searchPath)
searchPath
- if true, search PATHs.public void setSpawn(boolean spawn)
spawn
- if true you do not want Ant to wait for the end of the process.public void setTimeout(Integer value)
value
- timeout in milliseconds.public void setTimeout(Long value)
value
- timeout in milliseconds.protected void setupRedirector()
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.