|
@@ -42,12 +42,26 @@ public class Exec {
|
|
/**
|
|
/**
|
|
* Runs the specified command and saves each line of the command's output to
|
|
* Runs the specified command and saves each line of the command's output to
|
|
* the given list.
|
|
* the given list.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param command List containing command and all arguments
|
|
* @param command List containing command and all arguments
|
|
* @param output List in/out parameter to receive command output
|
|
* @param output List in/out parameter to receive command output
|
|
* @return int exit code of command
|
|
* @return int exit code of command
|
|
*/
|
|
*/
|
|
public int run(List<String> command, List<String> output) {
|
|
public int run(List<String> command, List<String> output) {
|
|
|
|
+ return this.run(command, output, null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 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.
|
|
|
|
+ *
|
|
|
|
+ * @param command List containing command and all arguments
|
|
|
|
+ * @param output List in/out parameter to receive command output
|
|
|
|
+ * @param errors List in/out parameter to receive command stderr
|
|
|
|
+ * @return int exit code of command
|
|
|
|
+ */
|
|
|
|
+ public int run(List<String> command, List<String> output,
|
|
|
|
+ List<String> errors) {
|
|
int retCode = 1;
|
|
int retCode = 1;
|
|
ProcessBuilder pb = new ProcessBuilder(command);
|
|
ProcessBuilder pb = new ProcessBuilder(command);
|
|
try {
|
|
try {
|
|
@@ -66,6 +80,9 @@ public class Exec {
|
|
stdOut.join();
|
|
stdOut.join();
|
|
stdErr.join();
|
|
stdErr.join();
|
|
output.addAll(stdOut.getOutput());
|
|
output.addAll(stdOut.getOutput());
|
|
|
|
+ if (errors != null) {
|
|
|
|
+ errors.addAll(stdErr.getOutput());
|
|
|
|
+ }
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
mojo.getLog().warn(command + " failed: " + ex.toString());
|
|
mojo.getLog().warn(command + " failed: " + ex.toString());
|
|
}
|
|
}
|