@@ -72,6 +72,39 @@ public static String execute(File workingDirectory, String executable, Object ..
7272 return outputBuffer .toString ();
7373 }
7474
75+ public static String execute2 (File workingDirectory , String executable , Object ... arguments ) throws MojoExecutionException {
76+ StringBuffer outputBuffer = new StringBuffer ();
77+ try {
78+
79+ arguments = expandArray (arguments );
80+
81+ Commandline command = new Commandline ();
82+ command .setWorkingDirectory (workingDirectory );
83+ command .setExecutable (executable );
84+ createArguments (command , arguments );
85+
86+ String line = StringUtils .join (command .getCommandline (), " " );
87+
88+ Process process = Runtime .getRuntime ().exec (line );
89+
90+ BufferedReader output = new BufferedReader (new InputStreamReader (process .getInputStream ()));
91+ BufferedReader error = new BufferedReader (new InputStreamReader (process .getErrorStream ()));
92+
93+ while (process .isAlive ()) {
94+ if (output .ready ()) outputBuffer .append (Logger .info (output .readLine ()) + "\n " );
95+ if (error .ready ()) Logger .error (error .readLine ());
96+ }
97+
98+ output .close ();
99+ error .close ();
100+
101+ } catch (IOException e ) {
102+ throw new MojoExecutionException (e .getMessage (), e );
103+ }
104+
105+ return outputBuffer .toString ();
106+ }
107+
75108 public static String execute (String executable , Object ... arguments ) throws MojoExecutionException {
76109 return execute (new File ("." ), executable , arguments );
77110 }
0 commit comments