@Deprecated public final class ExternalProcessBuilder extends Object implements Callable<Process>
Builder handle command, working directory, PATH
variable and HTTP proxy.
This class is immutable.
ExternalProcessBuilder.call()
Constructor and Description |
---|
ExternalProcessBuilder(String executable)
Deprecated.
Creates the new builder that will create the process by running
given executable.
|
Modifier and Type | Method and Description |
---|---|
ExternalProcessBuilder |
addArgument(String argument)
Deprecated.
Returns a builder with additional argument for the command.
|
ExternalProcessBuilder |
addEnvironmentVariable(String name,
String value)
Deprecated.
Returns a builder with additional environment variable for the command.
|
Process |
call()
Deprecated.
Creates the new
Process based on the properties configured
in this builder. |
ExternalProcessBuilder |
prependPath(File path)
Deprecated.
Returns a builder with additional path in
PATH variable. |
ExternalProcessBuilder |
redirectErrorStream(boolean redirectErrorStream)
Deprecated.
Returns a builder with configured error stream redirection.
|
ExternalProcessBuilder |
workingDirectory(File workingDirectory)
Deprecated.
Returns a builder with configured working directory.
|
@NonNull @CheckReturnValue public ExternalProcessBuilder workingDirectory(@NonNull File workingDirectory)
ExternalProcessBuilder.call()
method on returned builder
will be executed with this directory as current working dir.
The default value is undefined. Note that in such case each process has
working directory corresponding to the value of user.dir
system property.
All other properties of the returned builder are inherited from
this
.
workingDirectory
- working directory@NonNull @CheckReturnValue public ExternalProcessBuilder redirectErrorStream(boolean redirectErrorStream)
true
process subsequently created by
the ExternalProcessBuilder.call()
method on returned builder will redirect the error
stream to the standard output stream.
The default value is false
.
All other properties of the returned builder are inherited from
this
.
redirectErrorStream
- if true
error stream will be
redirected to standard output@NonNull @CheckReturnValue public ExternalProcessBuilder prependPath(@NonNull File path)
PATH
variable.
In the group of paths added by this call the last added path will
be the first one in the PATH
variable.
By default no additional paths are added to PATH
variable.
All other properties of the returned builder are inherited from
this
.
path
- path to add to PATH
variablePATH
variable@NonNull @CheckReturnValue public ExternalProcessBuilder addArgument(@NonNull String argument)
By default no additional arguments are passed to executable.
All other properties of the returned builder are inherited from
this
.
If there is a need to parse arguments already provided as one big
string the method that can help is
Utilities.parseParameters(java.lang.String)
.
argument
- command argument to add@NonNull @CheckReturnValue public ExternalProcessBuilder addEnvironmentVariable(@NonNull String name, @NonNull String value)
By default no additional environment variables are configured.
All other properties of the returned builder are inherited from
this
.
name
- name of the variablevalue
- value of the variableExternalProcessBuilder.call()
@NonNull public Process call() throws IOException
Process
based on the properties configured
in this builder. Created process will try to kill all its children on
call to Process.destroy()
.
Process is created by executing the executable with configured arguments.
If custom working directory is specified it is used otherwise value
of system property user.dir
is used as working dir.
Environment variables are prepared in following way:
ExternalProcessBuilder.addEnvironmentVariable(java.lang.String, java.lang.String)
.
This rewrites system variables if conflict occurs.
PATH
variable and append all paths added
by ExternalProcessBuilder.prependPath(java.io.File)
. The order of paths in PATH
variable is reversed to order of addition (the last added is the first
one in PATH
). Original content of PATH
follows
the added content.
http_proxy
nor HTTP_PROXY
environment variable is set then HTTP proxy settings configured in the
IDE are stored as http_proxy
environment variable
(the format of the value is http://username:password@host:port
).
call
in interface Callable<Process>
Process
based on the properties configured
in this builderIOException
- if the process could not be created