Save This Page
Home » apache-ant-1.7.1-src » org.apache.tools » ant » taskdefs » [javadoc | source]
org.apache.tools.ant.taskdefs
public class: Execute [javadoc | source]
java.lang.Object
   org.apache.tools.ant.taskdefs.Execute
Runs an external program.
Field Summary
public static final  int INVALID    Invalid exit code. set to Integer#MAX_VALUE  
Constructor:
 public Execute() 
 public Execute(ExecuteStreamHandler streamHandler) 
    Creates a new execute object.
    Parameters:
    streamHandler - the stream handler used to handle the input and output streams of the subprocess.
 public Execute(ExecuteStreamHandler streamHandler,
    ExecuteWatchdog watchdog) 
    Creates a new execute object.
    Parameters:
    streamHandler - the stream handler used to handle the input and output streams of the subprocess.
    watchdog - a watchdog for the subprocess or null to to disable a timeout for the subprocess.
Method from org.apache.tools.ant.taskdefs.Execute Summary:
closeStreams,   execute,   getCommandline,   getEnvironment,   getExitValue,   getProcEnvironment,   getWorkingDirectory,   isFailure,   isFailure,   killedProcess,   launch,   runCommand,   setAntRun,   setCommandline,   setEnvironment,   setExitValue,   setNewenvironment,   setSpawn,   setStreamHandler,   setVMLauncher,   setWorkingDirectory,   spawn,   toString,   waitFor
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.tools.ant.taskdefs.Execute Detail:
 public static  void closeStreams(Process process) 
    Close the streams belonging to the given Process.
 public int execute() throws IOException 
    Runs a process defined by the command line and returns its exit status.
 public String[] getCommandline() 
    Returns the commandline used to create a subprocess.
 public String[] getEnvironment() 
    Returns the environment used to create a subprocess.
 public int getExitValue() 
    Query the exit value of the process.
 public static synchronized Vector getProcEnvironment() 
    Find the list of environment variables for this process.
 public File getWorkingDirectory() 
    Return the working directory.
 public boolean isFailure() 
    Did this execute return in a failure.
 public static boolean isFailure(int exitValue) 
    Checks whether exitValue signals a failure on the current system (OS specific).

    Note that this method relies on the conventions of the OS, it will return false results if the application you are running doesn't follow these conventions. One notable exception is the Java VM provided by HP for OpenVMS - it will return 0 if successful (like on any other platform), but this signals a failure on OpenVMS. So if you execute a new Java VM on OpenVMS, you cannot trust this method.

 public boolean killedProcess() 
    Test for an untimely death of the process.
 public static Process launch(Project project,
    String[] command,
    String[] env,
    File dir,
    boolean useVM) throws IOException 
    Creates a process that runs a command.
 public static  void runCommand(Task task,
    String[] cmdline) throws BuildException 
    A utility method that runs an external command. Writes the output and error streams of the command to the project log.
 public  void setAntRun(Project project) throws BuildException 
    Set the name of the antRun script using the project's value.
 public  void setCommandline(String[] commandline) 
    Sets the commandline of the subprocess to launch.
 public  void setEnvironment(String[] env) 
    Sets the environment variables for the subprocess to launch.
 protected  void setExitValue(int value) 
    Set the exit value.
 public  void setNewenvironment(boolean newenv) 
    Set whether to propagate the default environment or not.
 public  void setSpawn(boolean spawn) 
    Set whether or not you want the process to be spawned. Default is not spawned.
 public  void setStreamHandler(ExecuteStreamHandler streamHandler) 
    Set the stream handler to use.
 public  void setVMLauncher(boolean useVMLauncher) 
    Launch this execution through the VM, where possible, rather than through the OS's shell. In some cases and operating systems using the shell will allow the shell to perform additional processing such as associating an executable with a script, etc.
 public  void setWorkingDirectory(File wd) 
    Sets the working directory of the process to execute.

    This is emulated using the antRun scripts unless the OS is Windows NT in which case a cmd.exe is spawned, or MRJ and setting user.dir works, or JDK 1.3 and there is official support in java.lang.Runtime.

 public  void spawn() throws IOException 
    Starts a process defined by the command line. Ant will not wait for this process, nor log its output.
 public static String toString(ByteArrayOutputStream bos) 
    ByteArrayOutputStream#toString doesn't seem to work reliably on OS/390, at least not the way we use it in the execution context.
 protected  void waitFor(Process process) 
    Wait for a given process.