Package org.robovm.compiler.util
Class Executor
java.lang.Object
org.robovm.compiler.util.Executor
- All Implemented Interfaces:
Launcher
public class Executor extends Object implements Launcher
Builder style wrapper around
commons-exec which also adds support for asynchronous
execution.-
Constructor Summary
-
Method Summary
Modifier and Type Method Description ExecutoraddEnv(String name, String value)Adds a single environment variable.Executorargs(Object... args)Adds one or more argument.Executorargs(Collection<Object> args)Adds arguments from the specifiedCollection.ExecutorcloseOutputStreams(boolean b)Sets whether the stdout and stderrOutputStreams should be closed after the command has finished.Executorenv(Map<String,String> env)Sets the environment variables for the child process.Executorerr(OutputStream err)Redirects the stderr stream of the child process to the specifiedOutputStream.ExecutorerrOut(OutputStream out)Redirects the stdout and stderr streams of the child process to the specifiedOutputStream.intexec()ProcessexecAsync()StringexecCapture()Executorin(InputStream in)Uses the specifiedInputStreamas the stdin stream for the child process.ExecutorinheritEnv(boolean b)Sets whether the parent's environment variables should be inherited by the child process.Executorout(OutputStream out)Redirects the stdout stream of the child process to the specifiedOutputStream.ExecutorstreamHandler(org.apache.commons.exec.ExecuteStreamHandler streamHandler)Sets theExecuteStreamHandlerto be used by the underlyingExecutor.Executorwd(File wd)Sets the working directory of the child process.
-
Constructor Details
-
Executor
Creates a new instance which will execute the specified command. -
Executor
Creates a new instance which will execute the specified command.
-
-
Method Details
-
args
Adds arguments from the specifiedCollection.Filearguments will be converted to absolute paths usingFile.getAbsolutePath(). All other types of args will be converted toStrings usingObject.toString().- Parameters:
args- the arguments to add.- Returns:
- this
Executor.
-
args
Adds one or more argument.Filearguments will be converted to absolute paths usingFile.getAbsolutePath(). All other types of args will be converted toStrings usingObject.toString().- Parameters:
args- the argument(s) to add.- Returns:
- this
Executor.
-
env
Sets the environment variables for the child process.- Parameters:
env- the environment variables.- Returns:
- this
Executor.
-
addEnv
Adds a single environment variable.- Parameters:
env- the environment variables.- Returns:
- this
Executor.
-
inheritEnv
Sets whether the parent's environment variables should be inherited by the child process. Defaults totrue.- Parameters:
b-trueorfalse.- Returns:
- this
Executor.
-
wd
Sets the working directory of the child process. If not set the working directory will be the same as the parent's.- Parameters:
wd- the working directory.- Returns:
- this
Executor.
-
errOut
Redirects the stdout and stderr streams of the child process to the specifiedOutputStream. If not specified stdout and stderr will be inherited from the parent process.- Parameters:
out- theOutputStream.- Returns:
- this
Executor.
-
out
Redirects the stdout stream of the child process to the specifiedOutputStream. If not specified stdout will be inherited from the parent process.- Parameters:
out- theOutputStream.- Returns:
- this
Executor.
-
err
Redirects the stderr stream of the child process to the specifiedOutputStream. If not specified stderr will be inherited from the parent process.- Parameters:
err- theOutputStream.- Returns:
- this
Executor.
-
in
Uses the specifiedInputStreamas the stdin stream for the child process.- Parameters:
in- theInputStream.- Returns:
- this
Executor.
-
streamHandler
Sets theExecuteStreamHandlerto be used by the underlyingExecutor. If set any streams set byout(OutputStream),err(OutputStream),errOut(OutputStream)orin(InputStream)will be ignored.- Parameters:
streamHandler- theExecuteStreamHandlerto be used.- Returns:
- this
Executor.
-
closeOutputStreams
Sets whether the stdout and stderrOutputStreams should be closed after the command has finished.- Parameters:
b-trueorfalse.
-
exec
- Throws:
org.apache.commons.exec.ExecuteExceptionIOException
-
execAsync
- Specified by:
execAsyncin interfaceLauncher- Throws:
IOException
-
execCapture
- Throws:
IOException
-