diff --git a/core/src/main/java/hudson/maven/PluginManagerInterceptor.java b/core/src/main/java/hudson/maven/PluginManagerInterceptor.java index 8cdbff9da1..89edd4f1fd 100644 --- a/core/src/main/java/hudson/maven/PluginManagerInterceptor.java +++ b/core/src/main/java/hudson/maven/PluginManagerInterceptor.java @@ -46,10 +46,6 @@ public class PluginManagerInterceptor implements PluginManagerListener, Lifecycl /** * Called by {@link MavenBuild} to connect this object to the rest of Hudson objects, * namely {@link MavenBuild}. - * - *

- * We can't do this in the constructor because this object is created by - * Plexus along with the rest of Maven objects. */ public PluginManagerInterceptor(MavenBuildProxy buildProxy, MavenReporter[] reporters, BuildListener listener) { this.buildProxy = buildProxy; @@ -60,31 +56,17 @@ public class PluginManagerInterceptor implements PluginManagerListener, Lifecycl /** * Called before the whole build. */ - public void preBuild(MavenSession session, ReactorManager rm, EventDispatcher dispatcher) throws BuildFailureException, LifecycleExecutionException { - try { - for (MavenReporter r : reporters) - r.preBuild(buildProxy,rm.getTopLevelProject(),listener); - } catch (InterruptedException e) { - throw new BuildFailureException("aborted",e); - } catch (IOException e) { - throw new BuildFailureException(e.getMessage(),e); - } + public void preBuild(MavenSession session, ReactorManager rm, EventDispatcher dispatcher) throws BuildFailureException, LifecycleExecutionException, IOException, InterruptedException { + for (MavenReporter r : reporters) + r.preBuild(buildProxy,rm.getTopLevelProject(),listener); } - public void postBuild(MavenSession session, ReactorManager rm, EventDispatcher dispatcher) throws BuildFailureException, LifecycleExecutionException { - try { - fireLeaveModule(); - buildProxy.setExecutedMojos(executedMojos); - for (MavenReporter r : reporters) - r.postBuild(buildProxy,rm.getTopLevelProject(),listener); - } catch (InterruptedException e) { - throw new BuildFailureException("aborted",e); - } catch (IOException e) { - throw new BuildFailureException(e.getMessage(),e); - } catch (AbortException e) { - throw new BuildFailureException("aborted",e); - } + public void postBuild(MavenSession session, ReactorManager rm, EventDispatcher dispatcher) throws BuildFailureException, LifecycleExecutionException, IOException, InterruptedException { + fireLeaveModule(); + buildProxy.setExecutedMojos(executedMojos); + for (MavenReporter r : reporters) + r.postBuild(buildProxy,rm.getTopLevelProject(),listener); } public void preExecute(MavenProject project, MojoExecution exec, PlexusConfiguration mergedConfig, ExpressionEvaluator eval) throws IOException, InterruptedException, AbortException { diff --git a/maven-interceptor/src/main/java/org/apache/maven/lifecycle/LifecycleExecutorInterceptor.java b/maven-interceptor/src/main/java/org/apache/maven/lifecycle/LifecycleExecutorInterceptor.java index 39f8ca2ccb..8d78fc4565 100644 --- a/maven-interceptor/src/main/java/org/apache/maven/lifecycle/LifecycleExecutorInterceptor.java +++ b/maven-interceptor/src/main/java/org/apache/maven/lifecycle/LifecycleExecutorInterceptor.java @@ -5,6 +5,10 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ReactorManager; import org.apache.maven.monitor.event.EventDispatcher; +import java.io.IOException; + +import hudson.maven.agent.AbortException; + /** * {@link LifecycleExecutor} interceptor. * @@ -29,13 +33,21 @@ public class LifecycleExecutorInterceptor extends DefaultLifecycleExecutor { } public void execute(MavenSession session, ReactorManager rm, EventDispatcher dispatcher) throws BuildFailureException, LifecycleExecutionException { - if(listener!=null) - listener.preBuild(session,rm,dispatcher); try { - super.execute(session, rm, dispatcher); - } finally { if(listener!=null) - listener.postBuild(session,rm,dispatcher); + listener.preBuild(session,rm,dispatcher); + try { + super.execute(session, rm, dispatcher); + } finally { + if(listener!=null) + listener.postBuild(session,rm,dispatcher); + } + } catch (InterruptedException e) { + throw new BuildFailureException("aborted",e); + } catch (IOException e) { + throw new BuildFailureException(e.getMessage(),e); + } catch (AbortException e) { + throw new BuildFailureException("aborted",e); } } } diff --git a/maven-interceptor/src/main/java/org/apache/maven/lifecycle/LifecycleExecutorListener.java b/maven-interceptor/src/main/java/org/apache/maven/lifecycle/LifecycleExecutorListener.java index 413d074a63..fa2b15903b 100644 --- a/maven-interceptor/src/main/java/org/apache/maven/lifecycle/LifecycleExecutorListener.java +++ b/maven-interceptor/src/main/java/org/apache/maven/lifecycle/LifecycleExecutorListener.java @@ -5,6 +5,8 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ReactorManager; import org.apache.maven.monitor.event.EventDispatcher; +import java.io.IOException; + /** * Event notification for the start/end of the maven execution. * @@ -16,6 +18,6 @@ import org.apache.maven.monitor.event.EventDispatcher; * @author Kohsuke Kawaguchi */ public interface LifecycleExecutorListener { - void preBuild(MavenSession session, ReactorManager rm, EventDispatcher dispatcher) throws BuildFailureException, LifecycleExecutionException; - void postBuild(MavenSession session, ReactorManager rm, EventDispatcher dispatcher) throws BuildFailureException, LifecycleExecutionException; + void preBuild(MavenSession session, ReactorManager rm, EventDispatcher dispatcher) throws BuildFailureException, LifecycleExecutionException, InterruptedException, IOException; + void postBuild(MavenSession session, ReactorManager rm, EventDispatcher dispatcher) throws BuildFailureException, LifecycleExecutionException, InterruptedException, IOException; }