diff --git a/core/src/main/java/hudson/maven/MavenBuild.java b/core/src/main/java/hudson/maven/MavenBuild.java index b292fb26be..1df52fef7c 100644 --- a/core/src/main/java/hudson/maven/MavenBuild.java +++ b/core/src/main/java/hudson/maven/MavenBuild.java @@ -230,7 +230,7 @@ public class MavenBuild extends AbstractBuild { ProxyImpl2(MavenModuleSetBuild parentBuild,SplittableBuildListener listener) throws FileNotFoundException { this.parentBuild = parentBuild; this.listener = listener; - log = new BufferedOutputStream(new FileOutputStream(getLogFile())); + log = new FileOutputStream(getLogFile()); // no buffering so that AJAX clients can see the log live } public void start() { @@ -257,19 +257,28 @@ public class MavenBuild extends AbstractBuild { } } - /** - * Gets the build for which this proxy is created. - */ - public MavenBuild owner() { - return MavenBuild.this; + public void appendLastLog() { + try { + listener.setSideOutputStream(log); + listener.setSideOutputStream(null); + } catch (IOException e) { + e.printStackTrace(); + } } /** - * Mark the build as aborted. This method is used when the aggregated build - * failed before it didn't even get to this module. + * Performs final clean up. Invoked after the entire aggregator build is completed. */ - protected void abortIfNotStarted() { + protected void close() { + try { + log.close(); + } catch (IOException e) { + e.printStackTrace(); + } + if(hasntStartedYet()) { + // Mark the build as aborted. This method is used when the aggregated build + // failed before it didn't even get to this module. run(new Runner() { public Result run(BuildListener listener) { listener.getLogger().println("Build failed before it gets to this module"); @@ -282,6 +291,13 @@ public class MavenBuild extends AbstractBuild { } } + /** + * Gets the build for which this proxy is created. + */ + public MavenBuild owner() { + return MavenBuild.this; + } + private Object writeReplace() { return Channel.current().export(MavenBuildProxy2.class,this); } diff --git a/core/src/main/java/hudson/maven/MavenBuildProxy2.java b/core/src/main/java/hudson/maven/MavenBuildProxy2.java index 1c346f6df1..30b0e64e3f 100644 --- a/core/src/main/java/hudson/maven/MavenBuildProxy2.java +++ b/core/src/main/java/hudson/maven/MavenBuildProxy2.java @@ -17,4 +17,12 @@ interface MavenBuildProxy2 extends MavenBuildProxy { * Notifies that the build has left a module. */ void end(); + + /** + * Maven produces additional error message after the module build is done. + * So to catch those messages, invoke this method on the last module that was built + * after all the Maven processing is done, to append last messages to the console + * output of the module. + */ + void appendLastLog(); } diff --git a/core/src/main/java/hudson/maven/MavenModuleSetBuild.java b/core/src/main/java/hudson/maven/MavenModuleSetBuild.java index 905dfeda13..081bcb77fc 100644 --- a/core/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/core/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -308,7 +308,7 @@ public final class MavenModuleSetBuild extends AbstractBuild> executedMojos = new HashMap>(); private long mojoStartTime; + private MavenBuildProxy2 lastProxy; public Builder(BuildListener listener,Map proxies, Collection modules, List goals, Map systemProps) { super(listener,goals,systemProps); @@ -365,6 +366,15 @@ public final class MavenModuleSetBuild extends AbstractBuild