|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.tools.ant.ProjectComponent | +--org.apache.tools.ant.Task | +--org.apache.tools.ant.taskdefs.ExecTask
Executes a given command if the os platform is appropriate.
Field Summary | |
protected Commandline |
cmdl
|
protected boolean |
failOnError
|
protected boolean |
newEnvironment
|
protected Redirector |
redirector
|
protected RedirectorElement |
redirectorElement
|
Fields inherited from class org.apache.tools.ant.Task |
description, location, target, taskName, taskType, wrapper |
Fields inherited from class org.apache.tools.ant.ProjectComponent |
project |
Constructor Summary | |
ExecTask()
|
Method Summary | |
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. |
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 searchPath)
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)
Sets 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)
File the error stream of the process is redirected to. |
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)
Sets a flag 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 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 |
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)
Sets a flag indicating 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 |
setSpawn(boolean spawn)
set whether or not you want the process to be spawned default is not spawned |
void |
setTimeout(java.lang.Integer value)
Timeout in milliseconds after which the process will be killed. |
void |
setTimeout(java.lang.Long value)
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)
Sets a flag indicating if we want to launch new process with VM, otherwise use the OS's shell. |
Methods inherited from class org.apache.tools.ant.Task |
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType |
Methods inherited from class org.apache.tools.ant.ProjectComponent |
getProject, setProject |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean failOnError
protected boolean newEnvironment
protected Commandline cmdl
protected Redirector redirector
protected RedirectorElement redirectorElement
Constructor Detail |
public ExecTask()
Method Detail |
public void setSpawn(boolean spawn)
spawn
- if true you do not want ant to wait for the end of the processpublic void setTimeout(java.lang.Long value)
value
- timeout in millisecondspublic void setTimeout(java.lang.Integer value)
value
- timeout in millisecondspublic void setExecutable(java.lang.String value)
value
- the name of the executable programpublic void setDir(java.io.File d)
d
- the working directory of the processpublic void setOs(java.lang.String os)
os
- list of operating systems on which the command may be executedpublic void setCommand(Commandline cmdl)
cmdl
- command linepublic void setOutput(java.io.File out)
out
- name of a file to which send output topublic void setInput(java.io.File input)
input
- name of a file to get input frompublic void setInputString(java.lang.String inputString)
inputString
- the string which is used as the input sourcepublic void setLogError(boolean logError)
logError
- set to true to log error output in the normal ant logpublic void setError(java.io.File error)
error
- a file to which send stderr topublic void setOutputproperty(java.lang.String outputProp)
outputProp
- name of propertypublic void setErrorProperty(java.lang.String errorProperty)
errorProperty
- name of propertypublic 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 executablepublic boolean getResolveExecutable()
public void addEnv(Environment.Variable var)
var
- new environment variablepublic Commandline.Argument createArg()
public void setResultProperty(java.lang.String resultProperty)
resultProperty
- name of propertyprotected void maybeSetResultPropertyValue(int result)
result
- value desired for the result property valuepublic void setFailIfExecutionFails(boolean flag)
flag
- stop the build if program cannot be startedpublic void setAppend(boolean append)
append
- if true append is desiredpublic void addConfiguredRedirector(RedirectorElement redirectorElement)
RedirectorElement
to this task.
redirectorElement
- RedirectorElement
.protected java.lang.String resolveExecutable(java.lang.String exec, boolean searchPath)
exec
- the name of the executablesearchPath
- if true, the excutable 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 parametersprotected void setupRedirector()
protected boolean isValidOs()
true
if the os under which ant is running is
matches one os in the os attribute
or if the os attribute is nullfalse
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 processprotected 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 circumstancesprotected ExecuteWatchdog createWatchdog() throws BuildException
BuildException
- under unknown circumstancesprotected void logFlush()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |