com.vaadin.hilla.engine.commandrunner.
Interface CommandRunner
All Known Implementing Classes:
A generic command runner which throws a CommandRunnerException
.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionString[]
Get the arguments to use when running the command.
default ProcessBuilder
createProcessBuilder
(List<String> commandWithArgs, boolean stdOut) Constructs a ProcessBuilder Instance using the passed in commands and arguments.
Get the directory to run the command in.
The custom environment variables needed for running the commands can be provided using this method.
Get the executables to try, in order of preference.
default ProcessHandle.Info
Fetches the Java executable path that initiated the current java process
org.slf4j.Logger
Get the logger to use.
default void
run
(Consumer<OutputStream> stdIn) Run the command.
default void
run
(Consumer<OutputStream> stdIn, boolean stdOut) Run the command.
String[]
Get the arguments to use when testing if the command is available.
-
Field Details
-
IS_WINDOWS
static final boolean IS_WINDOWS
-
-
Method Details
-
testArguments
String[] testArguments()Get the arguments to use when testing if the command is available.
Returns:
the arguments to use when testing if the command is available
-
arguments
String[] arguments()Get the arguments to use when running the command.
Returns:
the arguments to use when running the command
-
getLogger
org.slf4j.Logger getLogger()Get the logger to use.
Returns:
the logger to use
-
currentDirectory
File currentDirectory()Get the directory to run the command in.
Returns:
the directory to run the command in
-
executables
Get the executables to try, in order of preference.
Returns:
the executables to try
-
run
Run the command.
Parameters:
stdIn
- a Consumer that can be used to write to the command's standard input, can benull
if there's no need to write to it.Throws:
CommandRunnerException
- if the command fails -
run
Run the command.
Parameters:
stdIn
- a Consumer that can be used to write to the command's standard input, can benull
if there's no need to write to it.stdOut
- whether output and errors destination for the sub-process be the same as the parent process or notThrows:
CommandRunnerException
- if the command fails -
createProcessBuilder
Constructs a ProcessBuilder Instance using the passed in commands and arguments.
NOTE: This method uses the result of calling
environment()
to set the environment variables of the process to be constructed.Parameters:
commandWithArgs
- the command to be executed and its argumentsstdOut
- whether output and errors destination for the sub-process be the same as the parent process or notReturns:
a ProcessBuilder instance to be used for executing the passed in commands and arguments.
See Also:
-
getCurrentProcessInfo
Fetches the Java executable path that initiated the current java process
Returns:
An Optional of type String containing Java executable path or an empty Optional if it was not available.
-
environment
The custom environment variables needed for running the commands can be provided using this method.
NOTE: The provided environment variables by this method is added to the existing env of the ProcessBuilder, and in case of providing a duplicate key, it is overwriting the previously existing value.
Returns:
A java.util.Map containing the environment variables and their values that are used by the ProcessBuilder to execute the command.
-