@@ -63,7 +63,9 @@ public MavenExecutionResult exec(Path projectPath, String[] mavenArgs) {
6363 invoker .setMavenHome (new File (mavenHome ));
6464
6565 final ByteArrayOutputStream outBuf = new ByteArrayOutputStream ();
66+ final ByteArrayOutputStream errBuf = new ByteArrayOutputStream ();
6667 final PrintStream out = new PrintStream (outBuf );
68+ final PrintStream err = new PrintStream (errBuf );
6769
6870 InvocationResult result = null ;
6971 request .setPomFile (projectPath .resolve ("pom.xml" ).toFile ());
@@ -73,18 +75,29 @@ public MavenExecutionResult exec(Path projectPath, String[] mavenArgs) {
7375
7476 @ Override
7577 public void consumeLine (String line ) {
76- log .info ("MavenInvokator: m{}" , line );
77- out .append (line );
78+ log .info ("MavenInvokator: {}" , line );
79+ out .println (line );
80+ }
81+ });
82+ request .setErrorHandler (
83+ new InvocationOutputHandler () {
84+
85+ @ Override
86+ public void consumeLine (String line ) {
87+ log .info ("MavenInvokator: {}" , line );
88+ err .println (line );
7889 }
7990 });
8091
8192 request .setGoals (Arrays .asList (mavenArgs ));
8293
83- MavenExecutionResult compilationResult =
84- new MavenExecutionResult ().setStdOut (outBuf .toByteArray ()).setStdErr (new byte [0 ]);
94+ MavenExecutionResult compilationResult = new MavenExecutionResult ();
8595 try {
8696 result = invoker .execute (request );
8797 compilationResult .setExitCode (result .getExitCode ());
98+ // outBuf and errBuf are empty until invoker is executed
99+ compilationResult .setStdOut (outBuf .toByteArray ());
100+ compilationResult .setStdErr (errBuf .toByteArray ());
88101 CommandLineException exp = result .getExecutionException ();
89102 if (exp != null ) {
90103 throw new MavenExecutorException (exp );
0 commit comments