Package com.sap.cds.maven.plugin.util
Class ProcessExecutor
java.lang.Object
com.sap.cds.maven.plugin.util.ProcessExecutor
A class to execute subprocesses with a given command line in a specified working directory.
-
Constructor Summary
ConstructorsConstructorDescriptionProcessExecutor(File workingDir, org.apache.commons.exec.CommandLine cmdLine) Constructs newProcessExecutorinstance.ProcessExecutor(File workingDir, org.apache.commons.exec.CommandLine cmdLine, Map<String, String> env, List<String> paths) Constructs newProcessExecutorinstance. -
Method Summary
Modifier and TypeMethodDescriptionintexecute(OutputStream outputStream, OutputStream errOutputStream, CdsMojoLogger logger) executeAndGetResult(CdsMojoLogger logger) Executes the process.voidsetExitValues(int[] exitValues)
-
Constructor Details
-
ProcessExecutor
Constructs newProcessExecutorinstance.- Parameters:
workingDir- the working directory of the process to runcmdLine- the command line to execute
-
ProcessExecutor
public ProcessExecutor(File workingDir, org.apache.commons.exec.CommandLine cmdLine, Map<String, String> env, List<String> paths) Constructs newProcessExecutorinstance.- Parameters:
workingDir- the working directory of the process to runcmdLine- the command line to executeenv- additional environment variablespaths- 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 toerrOutputStream- the error output streamlogger- a requiredCdsMojoLogger- Returns:
- the return code
- Throws:
IOException- if execution failedorg.apache.commons.exec.ExecuteException- execution of subprocess failed or the subprocess returned an exit value indicating a failureExecutor.setExitValue(int).
-
executeAndGetResult
Executes the process.- Parameters:
logger- a requiredCdsMojoLogger- Returns:
- the console output of executed process
- Throws:
IOException- if process execution failedorg.apache.commons.exec.ExecuteException- execution of subprocess failed or the subprocess returned an exit value indicating a failureExecutor.setExitValue(int).
-
setExitValues
public void setExitValues(int[] exitValues)
-