| Modifier and Type | Field and Description |
|---|---|
| private static String | |
| private String[] | |
| private String[] | |
| private static boolean | environmentCaseInSensitive
Used for replacing env variables |
| private int | |
| public static final int | INVALID
Invalid exit code. |
| private boolean | |
| private static final int | |
| private static Map | |
| private static ProcessDestroyer | processDestroyer
Used to destroy processes when the VM exits. |
| private Project | |
| private ExecuteStreamHandler | |
| private boolean | useVMLauncher
Controls whether the VM is used to launch commands, where possible. |
| private final ExecuteWatchdog | |
| private File |
| Access | Constructor and Description |
|---|---|
| public | |
| public | Execute(ExecuteStreamHandler
the stream handler used to handle the input and
output streams of the subprocess. streamHandler)Creates a new execute object. |
| public | Execute(ExecuteStreamHandler
the stream handler used to handle the input and
output streams of the subprocess. streamHandler, ExecuteWatchdog a watchdog for the subprocess or watchdog)null
to disable a timeout for the subprocess.Creates a new execute object. |
| Modifier and Type | Method and Description |
|---|---|
| public static void | |
| public int | Returns: the exit status of the subprocess orINVALID.Runs a process defined by the command line and returns its exit status. |
| public String[] | Returns: the commandline used to create a subprocess.Returns the commandline used to create a subprocess. |
| public String[] | Returns: the environment used to create a subprocess.Returns the environment used to create a subprocess. |
| public static synchronized Map | Returns: a map containing the environment variables.Find the list of environment variables for this process. |
| public int | Returns: the exit value or Execute.INVALID if no exit value has been received.Query the exit value of the process. |
| private static String[] | Returns: command and arguments to get our environmentThis is the operation to get our environment. |
| public static synchronized Vector | Returns: a vector containing the environment variables. The vector elements are strings formatted like variable = value.
Deprecated
use #getEnvironmentVariables instead
Find the list of environment variables for this process.
|
| private static Map | |
| public File | |
| public static boolean | Returns: true if exitValue signals a failure.the exit value (return code) to be checked. exitValue)Checks whether |
| public boolean | Returns: true if and only if the exit code is interpreted as a failureDid this execute return in a failure. |
| public boolean | Returns: true if a watchdog had to kill the process.Test for an untimely death of the process. |
| public static Process | Returns: the process started.the Project, only used for logging purposes, may be null. project, String[] the command to run. command, String[] the environment for the command. env, File the working directory for the command. dir, boolean use the built-in exec command for JDK 1.3 if available. useVM)Creates a process that runs a command. |
| private String[] | Returns: the patched environment.Patch the current environment with the new values from the user. |
| public static void | runCommand(Task
The task that the command is part of. Used for logging task, String... The command to execute. cmdline)A utility method that runs an external command. |
| public void | |
| public void | setCommandline(String[]
the commandline of the subprocess to launch. commandline)Sets the commandline of the subprocess to launch. |
| public void | setEnvironment(String[]
array of Strings, each element of which has
an environment variable settings in format key=value. env)Sets the environment variables for the subprocess to launch. |
| protected void | |
| public void | setNewenvironment(boolean
whether to propagate the process environment. newenv)Set whether to propagate the default environment or not. |
| public void | setSpawn(boolean
if true you do not want Ant
to wait for the end of the process.
Has no influence in here, the calling task contains
and acts accordingly spawn)
Deprecated
Set whether or not you want the process to be spawned.
|
| public void | setStreamHandler(ExecuteStreamHandler
ExecuteStreamHandler. streamHandler)Set the stream handler to use. |
| public void | setVMLauncher(boolean
true if exec should launch through the VM,
false if the shell should be used to launch the
command. useVMLauncher)Launch this execution through the VM, where possible, rather than through the OS's shell. |
| public void | setWorkingDirectory(File
the working directory of the process. wd)Sets the working directory of the process to execute. |
| public void | |
| public static String | Returns: the output stream as a string, read with special encodings in the case of z/os and os/400.the output stream that one wants to read. 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 |
| antWorkingDirectory | back to summary |
|---|---|
| private static String antWorkingDirectory | |
| cmdl | back to summary |
|---|---|
| private String[] cmdl | |
| env | back to summary |
|---|---|
| private String[] env | |
| environmentCaseInSensitive | back to summary |
|---|---|
| private static boolean environmentCaseInSensitive Used for replacing env variables | |
| exitValue | back to summary |
|---|---|
| private int exitValue | |
| INVALID | back to summary |
|---|---|
| public static final int INVALID Invalid exit code. set to | |
| newEnvironment | back to summary |
|---|---|
| private boolean newEnvironment | |
| ONE_SECOND | back to summary |
|---|---|
| private static final int ONE_SECOND | |
| procEnvironment | back to summary |
|---|---|
| private static Map<String, String> procEnvironment | |
| processDestroyer | back to summary |
|---|---|
| private static ProcessDestroyer processDestroyer Used to destroy processes when the VM exits. | |
| project | back to summary |
|---|---|
| private Project project | |
| streamHandler | back to summary |
|---|---|
| private ExecuteStreamHandler streamHandler | |
| useVMLauncher | back to summary |
|---|---|
| private boolean useVMLauncher Controls whether the VM is used to launch commands, where possible. | |
| watchdog | back to summary |
|---|---|
| private final ExecuteWatchdog watchdog | |
| workingDirectory | back to summary |
|---|---|
| private File workingDirectory | |
| Execute | back to summary |
|---|---|
| public Execute() Creates a new execute object using | |
| Execute | back to summary |
|---|---|
| public Execute(ExecuteStreamHandler streamHandler) Creates a new execute object.
| |
| Execute | back to summary |
|---|---|
| public Execute(ExecuteStreamHandler streamHandler, ExecuteWatchdog watchdog) Creates a new execute object.
| |
| closeStreams | back to summary |
|---|---|
| public static void closeStreams(Process process) Close the streams belonging to the given Process.
| |
| execute | back to summary |
|---|---|
| public int execute() throws IOException Runs a process defined by the command line and returns its exit status.
| |
| getCommandline | back to summary |
|---|---|
| public String[] getCommandline() Returns the commandline used to create a subprocess.
| |
| getEnvironment | back to summary |
|---|---|
| public String[] getEnvironment() Returns the environment used to create a subprocess.
| |
| getEnvironmentVariables | back to summary |
|---|---|
| public static synchronized Map Find the list of environment variables for this process. | |
| getExitValue | back to summary |
|---|---|
| public int getExitValue() Query the exit value of the process.
| |
| getProcEnvCommand | back to summary |
|---|---|
| private static String[] getProcEnvCommand() This is the operation to get our environment. It is a notorious troublespot pre-Java1.5, and should be approached with extreme caution.
| |
| getProcEnvironment | back to summary |
|---|---|
| public static synchronized Vector Deprecated use #getEnvironmentVariables instead Find the list of environment variables for this process. | |
| getVMSLogicals | back to summary |
|---|---|
| private static Map This method is VMS specific and used by getEnvironmentVariables().
Parses VMS logicals from | |
| getWorkingDirectory | back to summary |
|---|---|
| public File getWorkingDirectory() Return the working directory.
| |
| isFailure | back to summary |
|---|---|
| public static boolean isFailure(int exitValue) Checks whether 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.
| |
| isFailure | back to summary |
|---|---|
| public boolean isFailure() Did this execute return in a failure.
| |
| killedProcess | back to summary |
|---|---|
| public boolean killedProcess() Test for an untimely death of the process.
| |
| launch | back to summary |
|---|---|
| public static Process launch(Project project, String[] command, String[] env, File dir, boolean useVM) throws IOException Creates a process that runs a command.
| |
| patchEnvironment | back to summary |
|---|---|
| private String[] patchEnvironment() Patch the current environment with the new values from the user.
| |
| runCommand | back to summary |
|---|---|
| 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.
| |
| setAntRun | back to summary |
|---|---|
| public void setAntRun(Project project) throws BuildException Set the name of the antRun script using the project's value.
| |
| setCommandline | back to summary |
|---|---|
| public void setCommandline(String[] commandline) Sets the commandline of the subprocess to launch.
| |
| setEnvironment | back to summary |
|---|---|
| public void setEnvironment(String[] env) Sets the environment variables for the subprocess to launch.
| |
| setExitValue | back to summary |
|---|---|
| protected void setExitValue(int value) Set the exit value.
| |
| setNewenvironment | back to summary |
|---|---|
| public void setNewenvironment(boolean newenv) Set whether to propagate the default environment or not.
| |
| setSpawn | back to summary |
|---|---|
| public void setSpawn(boolean spawn)
Deprecated
Set whether or not you want the process to be spawned. Default is not spawned.
| |
| setStreamHandler | back to summary |
|---|---|
| public void setStreamHandler(ExecuteStreamHandler streamHandler) Set the stream handler to use.
| |
| setVMLauncher | back to summary |
|---|---|
| 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.
| |
| setWorkingDirectory | back to summary |
|---|---|
| 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.
| |
| spawn | back to summary |
|---|---|
| public void spawn() throws IOException Starts a process defined by the command line. Ant will not wait for this process, nor log its output.
| |
| toString | back to summary |
|---|---|
| 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.
| |
| waitFor | back to summary |
|---|---|
| protected void waitFor(Process process) Wait for a given process.
| |