1 package org.jbpm.ant; 2 3 import java.io.BufferedReader ; 4 import java.io.IOException ; 5 import java.io.InputStreamReader ; 6 7 import org.apache.tools.ant.BuildException; 8 import org.apache.tools.ant.Task; 9 10 public class Launcher extends Thread { 11 12 Task task; 13 String command; 14 String endMsg; 15 16 public Launcher(Task task, String command, String endMsg) { 17 this.task = task; 18 this.command = command; 19 this.endMsg = endMsg; 20 } 21 22 public void run() { 23 try { 24 task.log("starting '" + command + "'..."); 25 Process process = Runtime.getRuntime().exec(command); 26 BufferedReader reader = new BufferedReader (new InputStreamReader (process.getInputStream())); 27 String line = ""; 28 while (line.indexOf(endMsg) == -1) { 29 line = reader.readLine(); 30 task.log(line); 31 } 32 task.log("'" + command + "' started."); 33 } catch (IOException e) { 34 throw new BuildException("couldn't start '" + command + "'", e); 35 } 36 } 37 38 } 39 | Popular Tags |