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

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

    java.lang.Object
      |
      +--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.

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, project, target, taskName, taskType, wrapper`

Constructor Summary
`ExecTask()`

Method Summary
`void` | `addEnv(Environment.Variable var)` Add a nested env element - an environment variable.
`protected void` | `checkConfiguration()` Has the user set all necessary attributes?
`Commandline.Argument` | `createArg()` Add a nested arg element - 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 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.
`void` | `setCommand(Commandline cmdl)` The full commandline to execute, executable + arguments.
`void` | `setDir(java.io.File d)` The working directory of the process
`void` | `setExecutable(java.lang.String value)` The command to execute.
`void` | `setFailonerror(boolean fail)` Throw a BuildException if process returns non 0.
`void` | `setNewenvironment(boolean newenv)` Use a completely new environment
`void` | `setOs(java.lang.String os)` Only execute the process if `os.name` is included in this string.
`void` | `setOutput(java.io.File out)` File the output of the process is redirected to.
`void` | `setTimeout(java.lang.Integer value)` Timeout in milliseconds after which the process will be killed.

Methods inherited from class org.apache.tools.ant.Task
`getDescription, getLocation, getOwningTarget, getProject, getRuntimeConfigurableWrapper, getTaskName, init, log, log, maybeConfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName`

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.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)

  Only execute the process if `os.name` is included in this string.

### setCommand

    public void setCommand(Commandline cmdl)

  The full commandline to execute, executable + arguments.

### setOutput

    public void setOutput(java.io.File out)

  File the output of the process is redirected to.

### setFailonerror

    public void setFailonerror(boolean fail)

  Throw a BuildException if process returns non 0.

### setNewenvironment

    public void setNewenvironment(boolean newenv)

  Use a completely new environment

### addEnv

    public void addEnv(Environment.Variable var)

  Add a nested env element - an environment variable.

### createArg

    public Commandline.Argument createArg()

  Add a nested arg element - a command line argument.

### execute

    public void execute()
                 throws BuildException

  Do the work.
  Overrides:
    `execute` in class `Task`
  Following copied from class: `org.apache.tools.ant.Task`
  Throws:
    `BuildException` - if someting goes wrong with the build

### checkConfiguration

    protected void checkConfiguration()
                               throws BuildException

  Has the user set all necessary attributes?

### isValidOs

    protected boolean isValidOs()

  Is this the OS the user wanted?

### prepareExec

    protected Execute prepareExec()
                           throws BuildException

  Create an Execute instance with the correct working directory set.

### runExec

    protected void runExec(Execute exe)
                    throws BuildException

  Run the command using the given Execute instance.

### createHandler

    protected ExecuteStreamHandler createHandler()
                                          throws BuildException

  Create the StreamHandler to use with our Execute instance.

### createWatchdog

    protected ExecuteWatchdog createWatchdog()
                                      throws BuildException

  Create the Watchdog to kill a runaway process.

### 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: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000 Apache Software Foundation. All Rights Reserved.