Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tools.ant.taskdefs
Class ExecTask

    java.lang.Object
      org.apache.tools.ant.ProjectComponent
          org.apache.tools.ant.Task
              org.apache.tools.ant.taskdefs.ExecTask

Direct Known Subclasses:
  ExecuteOn

public class ExecTask
extends Task

Executes a given command if the os platform is appropriate.

Since:
  Ant 1.2
Author:
  duncan@x180.com, rubys@us.ibm.com, thomas.haas@softwired-inc.com, Stefan Bodewig, Mariusz Nowostawski

Field Summary
`protected Commandline` | `cmdl`
`protected boolean` | `failOnError`
`protected boolean` | `newEnvironment`

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` | `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.
`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 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)` Whether output should be appended to or overwrite an existing file.
`void` | `setCommand(Commandline cmdl)`
`void` | `setDir(java.io.File d)` The working directory of the process.
`void` | `setExecutable(java.lang.String value)` The command to execute.
`void` | `setFailIfExecutionFails(boolean flag)` Stop the build if program cannot be started.
`void` | `setFailonerror(boolean fail)` Fail if the command exits with a non-zero return code.
`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)` Property name whose value should be set to the output of the process.
`void` | `setResultProperty(java.lang.String resultProperty)` The name of a property in which the return code of the command should be stored.
`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.
`void` | `setVMLauncher(boolean vmLauncher)` If true, 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, handleErrorFlush, handleErrorOutput, handleFlush, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName`

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

### failOnError

    protected boolean failOnError

### newEnvironment

    protected boolean newEnvironment

### cmdl

    protected Commandline cmdl

Constructor Detail

### ExecTask

    public ExecTask()

Method Detail

### setTimeout

    public void setTimeout(java.lang.Long value)

  Timeout in milliseconds after which the process will be killed.

  Since:
    Ant 1.5

### setTimeout

    public void setTimeout(java.lang.Integer value)

  Timeout in milliseconds after which the process will be killed.

### setExecutable

    public void setExecutable(java.lang.String value)

  The command to execute.

### setDir

    public void setDir(java.io.File d)

  The working directory of the process.

### setOs

    public void setOs(java.lang.String os)

  List of operating systems on which the command may be executed.

### setCommand

    public void setCommand(Commandline cmdl)

### setOutput

    public void setOutput(java.io.File out)

  File the output of the process is redirected to.

### setOutputproperty

    public void setOutputproperty(java.lang.String outputprop)

  Property name whose value should be set to the output of the process.

### setFailonerror

    public void setFailonerror(boolean fail)

  Fail if the command exits with a non-zero return code.

### setNewenvironment

    public void setNewenvironment(boolean newenv)

  Do not propagate old environment when new environment variables are specified.

### addEnv

    public void addEnv(Environment.Variable var)

  Add an environment variable to the launched process.

### createArg

    public Commandline.Argument createArg()

  Adds a command-line argument.

### setResultProperty

    public void setResultProperty(java.lang.String resultProperty)

  The name of a property in which the return code of the command should be stored. Only of interest if failonerror=false.

  Since:
    Ant 1.5

### maybeSetResultPropertyValue

    protected void maybeSetResultPropertyValue(int result)

  helper method to set result property to the passed in value if appropriate

### setFailIfExecutionFails

    public void setFailIfExecutionFails(boolean flag)

  Stop the build if program cannot be started. Defaults to true.

  Since:
    Ant 1.5

### setAppend

    public void setAppend(boolean append)

  Whether output should be appended to or overwrite an existing file. Defaults to false.

  Since:
    1.30, Ant 1.5

### execute

    public void execute()
                 throws BuildException

  Do the work.

  Overrides:
    `execute` in class `Task`
  Throws:
    `BuildException` - if something goes wrong with the build

### checkConfiguration

    protected void checkConfiguration()
                               throws BuildException

  Has the user set all necessary attributes?

  Throws:
    `BuildException`

### isValidOs

    protected boolean isValidOs()

  Is this the OS the user wanted?

### setVMLauncher

    public void setVMLauncher(boolean vmLauncher)

  If true, launch new process with VM, otherwise use the OS's shell.

### prepareExec

    protected Execute prepareExec()
                           throws BuildException

  Create an Execute instance with the correct working directory set.

  Throws:
    `BuildException`

### runExecute

    protected final void runExecute(Execute exe)
                             throws java.io.IOException

  A Utility method for this classes and subclasses to run an Execute instance (an external command).

  Throws:
    `java.io.IOException`

### runExec

    protected void runExec(Execute exe)
                    throws BuildException

  Run the command using the given Execute instance. This may be overidden by subclasses

  Throws:
    `BuildException`

### createHandler

    protected ExecuteStreamHandler createHandler()
                                          throws BuildException

  Create the StreamHandler to use with our Execute instance.

  Throws:
    `BuildException`

### createWatchdog

    protected ExecuteWatchdog createWatchdog()
                                      throws BuildException

  Create the Watchdog to kill a runaway process.

  Throws:
    `BuildException`

### logFlush

    protected void logFlush()

  Flush the output stream - if there is one.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.