Save This Page
Home » apache-ant-1.7.1-src » org.apache.tools » ant » taskdefs » [javadoc | source]
org.apache.tools.ant.taskdefs
public class: ExecTask [javadoc | source]
java.lang.Object
   org.apache.tools.ant.ProjectComponent
      org.apache.tools.ant.Task
         org.apache.tools.ant.taskdefs.ExecTask

All Implemented Interfaces:
    Cloneable

Direct Known Subclasses:
    Transform, Chgrp, AbstractAccessTask, Chown, ExecuteOn, Chmod, Attrib

Executes a given command if the os platform is appropriate.
Field Summary
protected  boolean failOnError     
protected  boolean newEnvironment     
protected  Commandline cmdl     
protected  Redirector redirector     
protected  RedirectorElement redirectorElement     
Fields inherited from org.apache.tools.ant.Task:
target,  taskName,  taskType,  wrapper
Fields inherited from org.apache.tools.ant.ProjectComponent:
project,  location,  description
Constructor:
 public ExecTask() 
 public ExecTask(Task owner) 
    create an instance that is helping another task. Project, OwningTarget, TaskName and description are all pulled out
    Parameters:
    owner - task that we belong to
Method from org.apache.tools.ant.taskdefs.ExecTask Summary:
addConfiguredRedirector,   addEnv,   checkConfiguration,   createArg,   createHandler,   createWatchdog,   execute,   getResolveExecutable,   isValidOs,   logFlush,   maybeSetResultPropertyValue,   prepareExec,   resolveExecutable,   runExec,   runExecute,   setAppend,   setCommand,   setDir,   setError,   setErrorProperty,   setExecutable,   setFailIfExecutionFails,   setFailonerror,   setInput,   setInputString,   setLogError,   setNewenvironment,   setOs,   setOsFamily,   setOutput,   setOutputproperty,   setResolveExecutable,   setResultProperty,   setSearchPath,   setSpawn,   setTimeout,   setTimeout,   setVMLauncher,   setupRedirector
Methods from org.apache.tools.ant.Task:
bindToOwner,   execute,   getOwningTarget,   getRuntimeConfigurableWrapper,   getTaskName,   getTaskType,   getWrapper,   handleErrorFlush,   handleErrorOutput,   handleFlush,   handleInput,   handleOutput,   init,   isInvalid,   log,   log,   log,   log,   markInvalid,   maybeConfigure,   perform,   reconfigure,   setOwningTarget,   setRuntimeConfigurableWrapper,   setTaskName,   setTaskType
Methods from org.apache.tools.ant.ProjectComponent:
clone,   getDescription,   getLocation,   getProject,   log,   log,   setDescription,   setLocation,   setProject
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.tools.ant.taskdefs.ExecTask Detail:
 public  void addConfiguredRedirector(RedirectorElement redirectorElement) 
    Add a RedirectorElement to this task.
 public  void addEnv(Environment.Variable var) 
    Add an environment variable to the launched process.
 protected  void checkConfiguration() throws BuildException 
    Has the user set all necessary attributes?
 public Commandline.Argument createArg() 
    Adds a command-line argument.
 protected ExecuteStreamHandler createHandler() throws BuildException 
    Create the StreamHandler to use with our Execute instance.
 protected ExecuteWatchdog createWatchdog() throws BuildException 
    Create the Watchdog to kill a runaway process.
 public  void execute() throws BuildException 
    Do the work.
 public 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() throws BuildException 
    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. We first try basedir, then the exec dir, and then fallback to the straight executable name (i.e. on the path).
 protected  void runExec(Execute exe) throws BuildException 
    Run the command using the given Execute instance. This may be overridden by subclasses.
 protected final  void runExecute(Execute exe) throws IOException 
    A Utility method for this classes and subclasses to run an Execute instance (an external command).
 public  void setAppend(boolean append) 
    Set whether output should be appended to or overwrite an existing file. Defaults to false.
 public  void setCommand(Commandline cmdl) 
    Sets a command line.
 public  void setDir(File d) 
    Set the working directory of the process.
 public  void setError(File error) 
    Set the File to which the error stream of the process should be redirected.
 public  void setErrorProperty(String errorProperty) 
    Sets the name of the property whose value should be set to the error of the process.
 public  void setExecutable(String value) 
    Set the name of the executable program.
 public  void setFailIfExecutionFails(boolean flag) 
    Set whether to stop the build if program cannot be started. Defaults to true.
 public  void setFailonerror(boolean fail) 
    Fail if the command exits with a non-zero return code.
 public  void setInput(File input) 
    Set the input file to use for the task.
 public  void setInputString(String inputString) 
    Set the string to use as input.
 public  void setLogError(boolean logError) 
    Controls whether error output of exec is logged. This is only useful when output is being redirected and error output is desired in the Ant log.
 public  void setNewenvironment(boolean newenv) 
    Do not propagate old environment when new environment variables are specified.
 public  void setOs(String os) 
    List of operating systems on which the command may be executed.
 public  void setOsFamily(String osFamily) 
    Restrict this execution to a single OS Family
 public  void setOutput(File out) 
    File the output of the process is redirected to. If error is not redirected, it too will appear in the output.
 public  void setOutputproperty(String outputProp) 
    Sets the property name whose value should be set to the output of the process.
 public  void setResolveExecutable(boolean resolveExecutable) 
    Set whether to attempt to resolve the executable to a file.
 public  void setResultProperty(String resultProperty) 
    Sets the name of a property in which the return code of the command should be stored. Only of interest if failonerror=false.
 public  void setSearchPath(boolean searchPath) 
    Set whether to search nested, then system PATH environment variables for the executable.
 public  void setSpawn(boolean spawn) 
    Set whether or not you want the process to be spawned. Default is false.
 public  void setTimeout(Long value) 
    Set the timeout in milliseconds after which the process will be killed.
 public  void setTimeout(Integer value) 
    Set the timeout in milliseconds after which the process will be killed.
 public  void setVMLauncher(boolean vmLauncher) 
    Set whether to launch new process with VM, otherwise use the OS's shell. Default value is true.
 protected  void setupRedirector() 
    Set up properties on the redirector that we needed to store locally.