com.vaadin.hilla.engine.commandrunner.

Interface CommandRunner

All Known Implementing Classes:

GradleRunner, MavenRunner

public interface CommandRunner

A generic command runner which throws a CommandRunnerException.

  • 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

      List<String> executables()

      Get the executables to try, in order of preference.

      Returns:

      the executables to try

    • run

      default void run(Consumer<OutputStream> stdIn) throws CommandRunnerException

      Run the command.

      Output and errors destination for the sub-process are the same as the parent process.

      Parameters:

      stdIn - a Consumer that can be used to write to the command's standard input, can be null if there's no need to write to it.

      Throws:

      CommandRunnerException - if the command fails

    • run

      default void run(Consumer<OutputStream> stdIn, boolean stdOut) throws CommandRunnerException

      Run the command.

      Parameters:

      stdIn - a Consumer that can be used to write to the command's standard input, can be null 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 not

      Throws:

      CommandRunnerException - if the command fails

    • createProcessBuilder

      default ProcessBuilder createProcessBuilder(List<String> commandWithArgs, boolean stdOut)

      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 arguments

      stdOut - whether output and errors destination for the sub-process be the same as the parent process or not

      Returns:

      a ProcessBuilder instance to be used for executing the passed in commands and arguments.

      See Also:

    • getCurrentProcessInfo

      default ProcessHandle.Info 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

      default Map<String,String> 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.