diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java index c138216695..1301be8586 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java @@ -15,6 +15,8 @@ package org.apache.maven.plugin; * the License. */ +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; import java.util.ArrayList; import java.util.List; @@ -113,9 +115,13 @@ public class DefaultBuildPluginManager } catch ( LinkageError e ) { - pluginRealm.display(); + ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 ); + PrintStream ps = new PrintStream( os ); + ps.println( "A linkage error occured while executing " + mojoDescriptor.getId() ); + ps.println( e ); + pluginRealm.display( ps ); - throw e; + throw new PluginExecutionException( mojoExecution, project, os.toString(), e ); } finally { diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginExecutionException.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginExecutionException.java index e16ffa93d2..3a3e5a3d4f 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/PluginExecutionException.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginExecutionException.java @@ -34,6 +34,12 @@ public class PluginExecutionException this.mojoExecution = mojoExecution; } + public PluginExecutionException( MojoExecution mojoExecution, MavenProject project, String message, Throwable cause ) + { + super( mojoExecution.getMojoDescriptor(), project, message, cause ); + this.mojoExecution = mojoExecution; + } + public PluginExecutionException( MojoExecution mojoExecution, MavenProject project, Exception cause ) { super( mojoExecution.getMojoDescriptor(), project, constructMessage( cause ), cause );