Class Exec
java.lang.Object
org.apache.hadoop.maven.plugin.util.Exec
Exec is a helper class for executing an external process from a mojo.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classOutputBufferThread is a background thread for consuming and storing output of the external process. -
Constructor Summary
ConstructorsConstructorDescriptionExec(org.apache.maven.plugin.Mojo mojo) Creates a new Exec instance for executing an external process from the given mojo. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddEnvironment(ProcessBuilder pb, Map<String, String> env) Add environment variables to a ProcessBuilder.static StringenvToString(Map<String, String> env) Pretty-print the environment to a StringBuilder.intRuns the specified command and saves each line of the command's output to the given list.intRuns the specified command and saves each line of the command's output to the given list and each line of the command's stderr to the other list.
-
Constructor Details
-
Exec
public Exec(org.apache.maven.plugin.Mojo mojo) Creates a new Exec instance for executing an external process from the given mojo.- Parameters:
mojo- Mojo executing external process
-
-
Method Details
-
run
Runs the specified command and saves each line of the command's output to the given list.- Parameters:
command- List containing command and all argumentsoutput- List in/out parameter to receive command output- Returns:
- int exit code of command
-
run
Runs the specified command and saves each line of the command's output to the given list and each line of the command's stderr to the other list.- Parameters:
command- List containing command and all argumentsoutput- List in/out parameter to receive command outputerrors- List in/out parameter to receive command stderr- Returns:
- int exit code of command
-
addEnvironment
Add environment variables to a ProcessBuilder.- Parameters:
pb- The ProcessBuilderenv- A map of environment variable names to values.
-
envToString
Pretty-print the environment to a StringBuilder.- Parameters:
env- A map of environment variable names to values to print.- Returns:
- The pretty-printed string.
-