From e9a7f3ce8509ed1aad5bf3e8264f30100a630825 Mon Sep 17 00:00:00 2001 From: Emmanuel Venisse Date: Wed, 4 May 2005 00:47:01 +0000 Subject: [PATCH] Initial version of site generation with repots. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@168031 13f79535-47bb-0310-9956-ffa450edef68 --- maven-core/pom.xml | 14 +++++-- .../apache/maven/execution/MavenSession.java | 13 +++++++ .../maven/plugin/DefaultPluginManager.java | 17 ++++++++- .../PluginParameterExpressionEvaluator.java | 38 +++++++++++++++++++ maven-plugins/maven-site-plugin/pom.xml | 10 ++--- .../org/apache/maven/doxia/DoxiaMojo.java | 26 +++++++------ .../maven-project-info-reports-plugin/pom.xml | 4 +- .../resources/META-INF/plexus/components.xml | 26 +++++++++++++ 8 files changed, 125 insertions(+), 23 deletions(-) diff --git a/maven-core/pom.xml b/maven-core/pom.xml index 61a87346ec..ad39f1e48b 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -49,6 +49,11 @@ maven-plugin-descriptor 2.0-SNAPSHOT + + org.apache.maven.reporting + maven-reporting-api + 2.0-SNAPSHOT + commons-cli commons-cli @@ -79,13 +84,14 @@ - + - org.apache.maven.reports - dependencies + org.apache.maven.plugins + maven-project-info-reports-plugin + 1.0-SNAPSHOT diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java index f7e61ceffc..2389f0c571 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java @@ -27,6 +27,7 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti import org.codehaus.plexus.context.Context; import java.util.List; +import java.util.Map; /** * @author Jason van Zyl @@ -126,6 +127,18 @@ public class MavenSession return container.lookup( role, roleHint ); } + public List lookupList( String role ) + throws ComponentLookupException + { + return container.lookupList( role ); + } + + public Map lookupMap( String role ) + throws ComponentLookupException + { + return container.lookupMap( role ); + } + public EventDispatcher getEventDispatcher() { return eventDispatcher; diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java index abe499f29d..2ec31e89d7 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java @@ -216,6 +216,21 @@ public class DefaultPluginManager } } + if ( project.getReports() != null ) + { + for ( Iterator it = project.getReports().getPlugins().iterator(); it.hasNext(); ) + { + org.apache.maven.model.Plugin plugin = (org.apache.maven.model.Plugin) it.next(); + + if ( groupId.equals( plugin.getGroupId() ) && artifactId.equals( plugin.getArtifactId() ) ) + { + pluginConfig = plugin; + + break; + } + } + } + String version = null; if ( pluginConfig != null ) @@ -791,7 +806,7 @@ public class DefaultPluginManager artifactFilter = new ExclusionSetFilter( new String[]{"maven-core", "maven-artifact", "maven-model", "maven-settings", "maven-monitor", "maven-plugin-api", "maven-plugin-descriptor", "plexus-container-default", - "maven-project", "plexus-container-artifact", + "maven-project", "plexus-container-artifact", "maven-reporting-api", "doxia-core", "wagon-provider-api", "classworlds", "maven-plugin"} ); } diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java index 69f31c38df..dcf3340180 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java @@ -16,14 +16,17 @@ package org.apache.maven.plugin; * limitations under the License. */ +import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.execution.MavenSession; import org.apache.maven.project.path.PathTranslator; +import org.apache.maven.reporting.MavenReport; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.util.introspection.ReflectionValueExtractor; import java.io.File; +import java.util.Iterator; /** * @author Jason van Zyl @@ -90,6 +93,41 @@ public class PluginParameterExpressionEvaluator throw new ExpressionEvaluationException( "Cannot lookup component: " + role + ".", e ); } } + else if (expression.equals( "reports" ) ) + { + String role = PluginManager.ROLE; + try + { + PluginManager pluginManager = (PluginManager) context.lookup( role ); + for ( Iterator it = context.getProject().getReports().getPlugins().iterator(); it.hasNext(); ) + { + org.apache.maven.model.Plugin plugin = (org.apache.maven.model.Plugin) it.next(); + pluginManager.verifyPlugin( plugin.getGroupId(), plugin.getArtifactId(), context ); + } + } + catch ( ComponentLookupException cle ) + { + throw new ExpressionEvaluationException( "Cannot lookup component: " + role + ".", cle ); + } + catch ( ArtifactResolutionException are ) + { + throw new ExpressionEvaluationException( "Cannot resolve component: " + role + ".", are ); + } + catch ( PluginManagerException pme ) + { + throw new ExpressionEvaluationException( "Cannot verify component: " + role + ".", pme ); + } + + role = MavenReport.ROLE; + try + { + value = context.lookupMap( role ); + } + catch ( ComponentLookupException cle ) + { + throw new ExpressionEvaluationException( "Cannot lookup component: " + role + ".", cle ); + } + } else if ( expression.equals( "localRepository" ) ) { value = context.getLocalRepository(); diff --git a/maven-plugins/maven-site-plugin/pom.xml b/maven-plugins/maven-site-plugin/pom.xml index abf56ea006..29c71feade 100644 --- a/maven-plugins/maven-site-plugin/pom.xml +++ b/maven-plugins/maven-site-plugin/pom.xml @@ -15,6 +15,11 @@ maven-project 2.0-SNAPSHOT + + org.apache.maven.reporting + maven-reporting-api + 2.0-SNAPSHOT + doxia doxia-core @@ -30,10 +35,5 @@ wagon-ssh 1.0-alpha-3-SNAPSHOT - - org.apache.maven.reporting - maven-reporting-manager - 2.0-SNAPSHOT - diff --git a/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java b/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java index 740c185f74..291002287f 100644 --- a/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java +++ b/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java @@ -4,17 +4,21 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.MavenReport; import org.apache.maven.reporting.MavenReportConfiguration; -import org.apache.maven.reporting.manager.MavenReportManager; import org.codehaus.doxia.site.renderer.SiteRenderer; import java.io.File; import java.util.Iterator; import java.util.List; +import java.util.Map; /** * @goal site * @description Doxia plugin + * + * @author Emmanuel Venisse + * @version $Id$ */ public class DoxiaMojo extends AbstractMojo @@ -32,7 +36,7 @@ public class DoxiaMojo private String generatedSiteDirectory; /** - * @parameter expressoin="${project.build.directory}/site" + * @parameter expression="${project.build.directory}/site" * @required */ private String outputDirectory; @@ -57,11 +61,11 @@ public class DoxiaMojo private MavenProject project; /** - * @parameter expression="${component.org.apache.maven.reporting.manager.MavenReportManager}" + * @parameter expression="${reports}" * @required * @readonly */ - private MavenReportManager reportManager; + private Map reports; /** * @parameter expression="${localRepository}" @@ -87,16 +91,16 @@ public class DoxiaMojo config.setModel( project.getModel() ); config.setOutputDirectory( new File( generatedSiteDirectory ) ); - - if ( project.getReports() != null ) + if ( reports != null ) { - reportManager.addReports( project.getReports(), localRepository, remoteRepositories ); - - for ( Iterator i = reportManager.getReports().keySet().iterator(); i.hasNext(); ) +System.out.println(reports.size()); + for ( Iterator i = reports.values().iterator(); i.hasNext(); ) { - String reportName = (String) i.next(); + MavenReport report = (MavenReport) i.next(); - reportManager.executeReport( reportName, config ); + report.setConfiguration( config ); + + report.generate(); } } diff --git a/sandbox/maven-reports/maven-project-info-reports-plugin/pom.xml b/sandbox/maven-reports/maven-project-info-reports-plugin/pom.xml index 950a52d1fa..da856747be 100644 --- a/sandbox/maven-reports/maven-project-info-reports-plugin/pom.xml +++ b/sandbox/maven-reports/maven-project-info-reports-plugin/pom.xml @@ -1,10 +1,10 @@ 4.0.0 - + org.apache.maven.plugins maven-project-info-reports-plugin 1.0-SNAPSHOT diff --git a/sandbox/maven-reports/maven-project-info-reports-plugin/src/main/resources/META-INF/plexus/components.xml b/sandbox/maven-reports/maven-project-info-reports-plugin/src/main/resources/META-INF/plexus/components.xml index 3a7c2c4a56..390745db25 100644 --- a/sandbox/maven-reports/maven-project-info-reports-plugin/src/main/resources/META-INF/plexus/components.xml +++ b/sandbox/maven-reports/maven-project-info-reports-plugin/src/main/resources/META-INF/plexus/components.xml @@ -12,4 +12,30 @@ per-lookup + + + doxia + doxia-core + jar + 1.0-alpha-2-SNAPSHOT + + + org.apache.maven.reporting + maven-reporting-api + jar + 2.0-SNAPSHOT + + + org.apache.maven + maven-model + jar + 2.0-SNAPSHOT + + + org.apache.maven + maven-plugin-api + jar + 2.0-SNAPSHOT + +