1 package com.ashlux.mavenoc4jplugin;
2
3 import org.apache.maven.plugin.logging.Log;
4
5 import java.io.IOException;
6
7 import com.ashlux.mavenoc4jplugin.log.LogLevel;
8 import com.ashlux.mavenoc4jplugin.log.LogStreamGobbler;
9
10 public class ProcessHelper {
11 private ProcessHelper() {
12 }
13
14 public static void startProcess(String command, Log log) throws InterruptedException, IOException {
15 Process process = Runtime.getRuntime().exec(command);
16 Thread processErrorLoggingThread =
17 new Thread(new LogStreamGobbler(process.getErrorStream(), log, LogLevel.ERROR));
18 Thread processStdinLoggingThread =
19 new Thread(new LogStreamGobbler(process.getInputStream(), log, LogLevel.INFO));
20 processErrorLoggingThread.start();
21 processStdinLoggingThread.start();
22 processStdinLoggingThread.join();
23 processErrorLoggingThread.join();
24 process.waitFor();
25 }
26 }