Class ProcessExecutor

java.lang.Object
com.sap.cds.maven.plugin.util.ProcessExecutor

public class ProcessExecutor extends Object
A class to execute subprocesses with a given command line in a specified working directory.
  • Constructor Details

    • ProcessExecutor

      public ProcessExecutor(File workingDir, org.apache.commons.exec.CommandLine cmdLine)
      Constructs new ProcessExecutor instance.
      Parameters:
      workingDir - the working directory of the process to run
      cmdLine - the command line to execute
    • ProcessExecutor

      public ProcessExecutor(File workingDir, org.apache.commons.exec.CommandLine cmdLine, Map<String,String> env, List<String> paths)
      Constructs new ProcessExecutor instance.
      Parameters:
      workingDir - the working directory of the process to run
      cmdLine - the command line to execute
      env - additional environment variables
      paths - a list of directories that will be added to path env. variable
  • Method Details

    • execute

      public int execute(OutputStream outputStream, OutputStream errOutputStream, CdsMojoLogger logger) throws IOException
      Parameters:
      outputStream - the output stream to write console output to
      errOutputStream - the error output stream
      logger - a required CdsMojoLogger
      Returns:
      the return code
      Throws:
      IOException - if execution failed
      org.apache.commons.exec.ExecuteException - execution of subprocess failed or the subprocess returned an exit value indicating a failure Executor.setExitValue(int).
    • executeAndGetResult

      public String executeAndGetResult(CdsMojoLogger logger) throws IOException
      Executes the process.
      Parameters:
      logger - a required CdsMojoLogger
      Returns:
      the console output of executed process
      Throws:
      IOException - if process execution failed
      org.apache.commons.exec.ExecuteException - execution of subprocess failed or the subprocess returned an exit value indicating a failure Executor.setExitValue(int).
    • setExitValues

      public void setExitValues(int[] exitValues)