@@ -63,7 +63,9 @@ public MavenExecutionResult exec(Path projectPath, String[] mavenArgs) {
63
63
invoker .setMavenHome (new File (mavenHome ));
64
64
65
65
final ByteArrayOutputStream outBuf = new ByteArrayOutputStream ();
66
+ final ByteArrayOutputStream errBuf = new ByteArrayOutputStream ();
66
67
final PrintStream out = new PrintStream (outBuf );
68
+ final PrintStream err = new PrintStream (errBuf );
67
69
68
70
InvocationResult result = null ;
69
71
request .setPomFile (projectPath .resolve ("pom.xml" ).toFile ());
@@ -73,18 +75,29 @@ public MavenExecutionResult exec(Path projectPath, String[] mavenArgs) {
73
75
74
76
@ Override
75
77
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 );
78
89
}
79
90
});
80
91
81
92
request .setGoals (Arrays .asList (mavenArgs ));
82
93
83
- MavenExecutionResult compilationResult =
84
- new MavenExecutionResult ().setStdOut (outBuf .toByteArray ()).setStdErr (new byte [0 ]);
94
+ MavenExecutionResult compilationResult = new MavenExecutionResult ();
85
95
try {
86
96
result = invoker .execute (request );
87
97
compilationResult .setExitCode (result .getExitCode ());
98
+ // outBuf and errBuf are empty until invoker is executed
99
+ compilationResult .setStdOut (outBuf .toByteArray ());
100
+ compilationResult .setStdErr (errBuf .toByteArray ());
88
101
CommandLineException exp = result .getExecutionException ();
89
102
if (exp != null ) {
90
103
throw new MavenExecutorException (exp );
0 commit comments