You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2009/08/05 01:37:16 UTC
svn commit: r801022 -
/maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/AbstractSiteRenderingMojo.java
Author: olamy
Date: Tue Aug 4 23:37:16 2009
New Revision: 801022
URL: http://svn.apache.org/viewvc?rev=801022&view=rev
Log:
check implementationClass before trying to load the mojo.
Modified:
maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/AbstractSiteRenderingMojo.java
Modified: maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/AbstractSiteRenderingMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/AbstractSiteRenderingMojo.java?rev=801022&r1=801021&r2=801022&view=diff
==============================================================================
--- maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/AbstractSiteRenderingMojo.java (original)
+++ maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/AbstractSiteRenderingMojo.java Tue Aug 4 23:37:16 2009
@@ -30,6 +30,7 @@
import java.util.Locale;
import java.util.Map;
+import org.apache.maven.Maven;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolver;
@@ -334,26 +335,63 @@
}
return reports;
}
- catch ( Exception e )
+ catch ( Throwable e )
{
throw new MojoExecutionException( "failed to get Reports ", e );
}
}
private MavenReport getConfiguredMavenReport( MojoExecution mojoExecution, ClassRealm pluginRealm )
- throws PluginConfigurationException, PluginManagerException, MojoExecutionException, MojoFailureException
+ throws Throwable
{
- Mojo mojo =
- (Mojo) pluginManager.getConfiguredMojo( Mojo.class, mavenSession, project, mojoExecution, pluginRealm );
- lifecycleExecutor.populateMojoExecutionConfiguration( project, mojoExecution, false );
- if ( mojo instanceof MavenReport )
+ if ( !isMavenReport( mojoExecution, pluginRealm ) )
{
- return (MavenReport) mojo;
+ return null;
+ }
+ try
+ {
+ lifecycleExecutor.extractMojoConfiguration( mojoExecution );
+
+ Mojo mojo =
+ (Mojo) pluginManager.getConfiguredMojo( Mojo.class, mavenSession, project, mojoExecution, pluginRealm );
+
+ lifecycleExecutor.populateMojoExecutionConfiguration( project, mojoExecution, false );
+
+ if ( mojo instanceof MavenReport )
+ {
+ return (MavenReport) mojo;
+ }
+ getLog().info( "mojo " + mojo.getClass() + " cannot be a MavenReport so nothing will be executed " );
+ return null;
+ }
+ catch ( Throwable e )
+ {
+ getLog().error( "error configuring mojo " + mojoExecution.toString() );
+ throw e;
}
- getLog().info( "mojo " + mojo.getClass() + " cannot be a MavenReport so nothing will be executed " );
- return null;
}
+ private boolean isMavenReport( MojoExecution mojoExecution, ClassRealm pluginRealm )
+ {
+ ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader( pluginRealm );
+ Class clazz = mojoExecution.getMojoDescriptor().getImplementationClass();
+ boolean isMavenReport = MavenReport.class.isAssignableFrom( clazz );
+ if (!isMavenReport)
+ {
+ getLog().info( " skip non MavenReport " + mojoExecution.getMojoDescriptor().getId() );
+ }
+ return isMavenReport;
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader( originalClassLoader );
+ }
+
+ }
+
/**
* @param pluginDescriptor
* @return