org.apache.tools.ant.taskdefs
public class ExecTask extends Task
Since: Ant 1.2
UNKNOWN: category="control"
Field Summary | |
---|---|
protected Commandline | cmdl |
protected boolean | failOnError |
protected boolean | newEnvironment |
protected Redirector | redirector |
protected RedirectorElement | redirectorElement |
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 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 | 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(Long value)
Set the timeout in milliseconds after which the process will be killed.
|
void | setTimeout(Integer 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.
|
RedirectorElement
to this task.
Parameters: redirectorElement RedirectorElement
.
Since: Ant 1.6.2
Parameters: var new environment variable.
Throws: BuildException if there are missing required parameters.
Returns: new command line argument created.
Returns: instance of ExecuteStreamHandler.
Throws: BuildException under unknown circumstances.
Returns: instance of ExecuteWatchdog.
Throws: BuildException under unknown circumstances.
Throws: BuildException in a number of circumstances:
Since: Ant 1.6
Returns: boolean.
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.
Parameters: result value desired for the result property value.
Returns: an instance of the Execute class.
Throws: BuildException under unknown circumstances.
Parameters: 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.
Returns: the executable as a full path if it can be determined.
Since: Ant 1.6
Parameters: exe instance of Execute to run.
Throws: BuildException if the new process could not be started only if failIfExecFails is set to true (the default).
Parameters: exe instance of the execute class.
Throws: IOException in case of problem to attach to the stdin/stdout/stderr streams of the process.
Parameters: append if true append is desired.
Since: 1.30, Ant 1.5
Parameters: cmdl command line.
UNKNOWN: ignore="true"
Parameters: d the working directory of the process.
Parameters: error a file to which stderr should be sent.
Since: Ant 1.6
Parameters: errorProperty name of property.
Since: Ant 1.6
Parameters: value the name of the executable program.
Parameters: flag stop the build if program cannot be started.
Since: Ant 1.5
Parameters: fail if true fail the command on non-zero return code.
Parameters: input name of a file from which to get input.
Parameters: inputString the string which is used as the input source.
Parameters: logError set to true to log error output in the normal ant log.
Parameters: newenv if true, do not propagate old environment when new environment variables are specified.
Parameters: os list of operating systems on which the command may be executed.
Parameters: out name of a file to which output should be sent.
Parameters: outputProp name of property.
Parameters: resolveExecutable if true, attempt to resolve the path of the executable.
Parameters: resultProperty name of property.
Since: Ant 1.5
Parameters: searchPath if true, search PATHs.
Parameters: spawn if true you do not want Ant to wait for the end of the process.
Since: Ant 1.6
Parameters: value timeout in milliseconds.
Since: Ant 1.5
Parameters: value timeout in milliseconds.
Parameters: vmLauncher true if we want to launch new process with VM, false if we want to use the OS's shell.