/** * Start the process, writing the stdout and stderr to consumer. * * @param pb process builder to start * @param consumer a consumer where stdout and stderr will be redirected * @return the started process * @throws IOException */ public static Process execute(ProcessBuilder pb, LineConsumer consumer) throws IOException { pb.redirectErrorStream(true); Process process = pb.start(); process(process, consumer); return process; }
@Override public void cancel() { ProcessUtil.kill(process); if (callback != null) { callback.cancelled(this); } } }
private static void readMavenVersionInformation(LineConsumer cmdOutput) throws IOException { final CommandLine commandLine = new CommandLine(getMavenExecCommand()).add("-version"); final ProcessBuilder processBuilder = new ProcessBuilder().command(commandLine.toShellCommand()).redirectErrorStream(true); final Process process = processBuilder.start(); ProcessUtil.process(process, cmdOutput, LineConsumer.DEV_NULL); } }
ProcessUtil.process(Runtime.getRuntime().exec(ps), stdout, stderr); } catch (IOException e) { throw new IllegalStateException(e);
ProcessUtil.process(process, stdout);