// NOTE: DuplicateArtifactAttachmentException is currently unchecked, so be careful removing this try/catch!
// This is necessary to avoid creating compatibility problems for existing plugins that use
// MavenProjectHelper.attachArtifact(..).
try
{
MojoExecutionEvent mojoExecutionEvent = new MojoExecutionEvent( session, project, mojoExecution, mojo );
mojoExecutionListener.beforeMojoExecution( mojoExecutionEvent );
mojo.execute();
mojoExecutionListener.afterMojoExecutionSuccess( mojoExecutionEvent );
}
catch ( ClassCastException e )
{
// to be processed in the outer catch block
throw e;
}
catch ( RuntimeException e )
{
throw new PluginExecutionException( mojoExecution, project, e );
}
}
catch ( PluginContainerException e )
{
mojoExecutionListener.afterExecutionFailure( new MojoExecutionEvent( session, project, mojoExecution, mojo,
e ) );
throw new PluginExecutionException( mojoExecution, project, e );
}
catch ( NoClassDefFoundError e )
{
mojoExecutionListener.afterExecutionFailure( new MojoExecutionEvent( session, project, mojoExecution, mojo,
e ) );
ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 );
PrintStream ps = new PrintStream( os );
ps.println( "A required class was missing while executing " + mojoDescriptor.getId() + ": "
+ e.getMessage() );
pluginRealm.display( ps );
Exception wrapper = new PluginContainerException( mojoDescriptor, pluginRealm, os.toString(), e );
throw new PluginExecutionException( mojoExecution, project, wrapper );
}
catch ( LinkageError e )
{
mojoExecutionListener.afterExecutionFailure( new MojoExecutionEvent( session, project, mojoExecution, mojo,
e ) );
ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 );
PrintStream ps = new PrintStream( os );
ps.println( "An API incompatibility was encountered while executing " + mojoDescriptor.getId() + ": "
+ e.getClass().getName() + ": " + e.getMessage() );
pluginRealm.display( ps );
Exception wrapper = new PluginContainerException( mojoDescriptor, pluginRealm, os.toString(), e );
throw new PluginExecutionException( mojoExecution, project, wrapper );
}
catch ( ClassCastException e )
{
mojoExecutionListener.afterExecutionFailure( new MojoExecutionEvent( session, project, mojoExecution, mojo,
e ) );
ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 );
PrintStream ps = new PrintStream( os );
ps.println( "A type incompatibility occured while executing " + mojoDescriptor.getId() + ": "
+ e.getMessage() );
pluginRealm.display( ps );
throw new PluginExecutionException( mojoExecution, project, os.toString(), e );
}
catch ( RuntimeException e )
{
mojoExecutionListener.afterExecutionFailure( new MojoExecutionEvent( session, project, mojoExecution, mojo,
e ) );
throw e;
}
finally