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/22 08:19:45 UTC
svn commit: r806794 - in /maven/plugins/branches/maven-site-plugin-3.x:
pom.xml
src/main/java/org/apache/maven/plugins/site/AbstractSiteRenderingMojo.java
Author: olamy
Date: Sat Aug 22 06:19:45 2009
New Revision: 806794
URL: http://svn.apache.org/viewvc?rev=806794&view=rev
Log:
fix mojo check when testing if it's a build mojo or a report
Modified:
maven/plugins/branches/maven-site-plugin-3.x/pom.xml
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/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-site-plugin-3.x/pom.xml?rev=806794&r1=806793&r2=806794&view=diff
==============================================================================
--- maven/plugins/branches/maven-site-plugin-3.x/pom.xml (original)
+++ maven/plugins/branches/maven-site-plugin-3.x/pom.xml Sat Aug 22 06:19:45 2009
@@ -339,7 +339,7 @@
<version>${project.version}</version>
</plugin>
</plugins>
- </pluginManagement>
+ </pluginManagement>
</build>
<reporting>
@@ -434,6 +434,11 @@
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.2-SNAPSHOT</version>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.6.1-SNAPSHOT</version>
+ </plugin>
</plugins>
</reporting>
</profile>
@@ -458,7 +463,6 @@
<mappingId>customizable</mappingId>
<configurators>
<configurator id='org.maven.ide.eclipse.jdt.javaConfigurator' />
- <configurator id='org.maven.ide.eclipse.modello.modelloConfigurator' />
<configurator id='org.maven.ide.eclipse.plexus.annotations.plexusConfigurator' />
</configurators>
<mojoExecutions>
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=806794&r1=806793&r2=806794&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 Sat Aug 22 06:19:45 2009
@@ -283,18 +283,22 @@
throws MojoExecutionException
{
List<String> imports = new ArrayList<String>();
+
imports.add( "org.apache.maven.reporting.MavenReport" );
- imports.add( "org.apache.maven.reporting.AbstractMavenReport" );
+ //imports.add( "org.apache.maven.reporting.AbstractMavenReport" );
+ imports.add( "org.apache.maven.doxia.siterenderer.Renderer" );
imports.add( "org.apache.maven.doxia.sink.SinkFactory" );
imports.add( "org.codehaus.doxia.sink.Sink" );
imports.add( "org.apache.maven.doxia.sink.Sink" );
imports.add( "org.apache.maven.doxia.sink.SinkEventAttributes" );
+
+ /*
imports.add( "org.codehaus.plexus.util.xml.Xpp3Dom" );
imports.add( "org.codehaus.plexus.util.xml.pull.XmlPullParser" );
imports.add( "org.codehaus.plexus.util.xml.pull.XmlPullParserException" );
imports.add( "org.codehaus.plexus.util.xml.pull.XmlSerializer" );
-
+ */
RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
repositoryRequest.setLocalRepository( localRepository );
@@ -336,14 +340,12 @@
MojoDescriptor mojoDescriptor =
mavenPluginManager.getMojoDescriptor( plugin, goal, repositoryRequest );
- MojoExecution mojoExecution = new MojoExecution( plugin, goal, "report" + goal );
+ MojoExecution mojoExecution = new MojoExecution( plugin, goal, "report:" + goal );
mojoExecution.setConfiguration( convert( mojoDescriptor ) );
mojoExecution.setMojoDescriptor( mojoDescriptor );
mavenPluginManager.setupPluginRealm( pluginDescriptor, mavenSession, Thread.currentThread().getContextClassLoader(), imports );
- //ClassRealm pluginRealm = getMojoReportRealm( mojoDescriptor.getPluginDescriptor() );
- //pluginDescriptor.setClassRealm( pluginRealm );
- MavenReport mavenReport = getConfiguredMavenReport( mojoExecution, pluginDescriptor.getClassRealm() );
+ MavenReport mavenReport = getConfiguredMavenReport( mojoExecution, pluginDescriptor );
if (mavenReport != null)
{
reports.put( mavenReport, pluginDescriptor.getClassRealm() );
@@ -358,59 +360,48 @@
}
}
- private MavenReport getConfiguredMavenReport( MojoExecution mojoExecution, ClassRealm pluginRealm )
+ private MavenReport getConfiguredMavenReport( MojoExecution mojoExecution, PluginDescriptor pluginDescriptor )
throws Throwable
{
- if ( !isMavenReport( mojoExecution, pluginRealm ) )
+ if ( !isMavenReport( mojoExecution, pluginDescriptor ) )
{
return null;
}
try
{
- //lifecycleExecutor.extractMojoConfiguration( mojoExecution );
-
MavenReport mavenReport = mavenPluginManager.getConfiguredMojo( MavenReport.class, this.mavenSession, mojoExecution );
return mavenReport;
- /*
- 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 " );
+ } catch (ClassCastException e)
+ {
+ getLog().warn( "skip ClassCastException " + e.getMessage() );
return null;
- */
}
catch ( Throwable e )
{
- getLog().error( "error configuring mojo " + mojoExecution.toString() );
+ getLog().error( "error configuring mojo " + mojoExecution.toString() + " : " + e.getMessage() , e);
throw e;
}
}
- private boolean isMavenReport( MojoExecution mojoExecution, ClassRealm pluginRealm )
+ private boolean isMavenReport( MojoExecution mojoExecution, PluginDescriptor pluginDescriptor )
{
- String className = null;
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try
{
- Thread.currentThread().setContextClassLoader( pluginRealm );
- className = mojoExecution.getMojoDescriptor().getImplementation();
- Class<?> clazz = Class.forName( className );
- boolean isMavenReport = MavenReport.class.isAssignableFrom( clazz );
+ MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( mojoExecution.getGoal() );
+ Thread.currentThread().setContextClassLoader( mojoDescriptor.getRealm() );
+ boolean isMavenReport = MavenReport.class.isAssignableFrom( mojoDescriptor.getImplementationClass() );
if (!isMavenReport)
{
getLog().info( " skip non MavenReport " + mojoExecution.getMojoDescriptor().getId() );
}
return isMavenReport;
}
- catch ( ClassNotFoundException e )
+ catch ( LinkageError e )
{
- getLog().warn( "skip ClassNotFoundException " + className );
+ getLog().warn( "skip LinkageError mojoExecution.goal" + mojoExecution.getGoal() + " : " + e.getMessage(), e );
+ //pluginRealm.display();
return false;
}
finally
@@ -420,31 +411,6 @@
}
- /**
- * @param pluginDescriptor
- * @return
- * @throws PluginManagerException
- */
- /*
- private ClassRealm getMojoReportRealms( PluginDescriptor pluginDescriptor )
- throws PluginManagerException
- {
- ClassRealm sitePluginRealm = (ClassRealm) Thread.currentThread().getContextClassLoader();
- List<String> imported = new ArrayList<String>();
-
- imported.add( "org.apache.maven.reporting.MavenReport" );
- imported.add( "org.codehaus.doxia.sink.Sink" );
- imported.add( "org.apache.maven.doxia.sink.Sink" );
- imported.add( "org.apache.maven.doxia.sink.SinkEventAttributes" );
- imported.add( "org.codehaus.plexus.util.xml.Xpp3Dom" );
- imported.add( "org.codehaus.plexus.util.xml.pull.XmlPullParser" );
- imported.add( "org.codehaus.plexus.util.xml.pull.XmlPullParserException" );
- imported.add( "org.codehaus.plexus.util.xml.pull.XmlSerializer" );
-
- return pluginManager.getPluginRealm( mavenSession, pluginDescriptor, sitePluginRealm, imported );
- }
- */
-
protected Map<MavenReport, ClassLoader> filterReports( Map<MavenReport, ClassLoader> reports )
{
Map<MavenReport, ClassLoader> filteredReports = new HashMap<MavenReport, ClassLoader>();