diff --git a/maven-core/src/main/java/org/apache/maven/execution/ExecutionListener.java b/maven-core/src/main/java/org/apache/maven/execution/ExecutionListener.java index 91fa945938..becca712f4 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/ExecutionListener.java +++ b/maven-core/src/main/java/org/apache/maven/execution/ExecutionListener.java @@ -1,5 +1,8 @@ package org.apache.maven.execution; +import org.apache.maven.plugin.MojoExecution; + + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -49,6 +52,10 @@ public interface ExecutionListener void mojoSucceeded( ExecutionEvent event ); + /** + * since 3.0.2 {@link Exception} is in {@link MojoExecution#getException()} returned + * by {@link ExecutionEvent#getMojoExecution()} + */ void mojoFailed( ExecutionEvent event ); void forkStarted( ExecutionEvent event ); diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java index 3f8985df8e..b8257e2674 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java @@ -215,6 +215,7 @@ public class MojoExecutor } catch ( LifecycleExecutionException e ) { + mojoExecution.setException( new Exception( e.getCause() ) ); eventCatapult.fire( ExecutionEvent.Type.MojoFailed, session, mojoExecution ); throw e; diff --git a/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java b/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java index d16a8bd54f..420a214413 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java @@ -39,6 +39,11 @@ public class MojoExecution private MojoDescriptor mojoDescriptor; private Xpp3Dom configuration; + + /** + * @since 3.0.2 + */ + private Exception exception; /** * Describes the source of an execution. @@ -234,4 +239,23 @@ public class MojoExecution this.forkedExecutions.put( projectKey, forkedExecutions ); } + /** + * @since 3.0.2 + * @return {@link Exception} encountered during the execution + */ + public Exception getException() + { + return exception; + } + + /** + * @since 3.0.2 + * @param exception + */ + public MojoExecution setException( Exception exception ) + { + this.exception = exception; + return this; + } + }