diff --git a/maven-plugin-plugin/src/it/plugin-report/pom.xml b/maven-plugin-plugin/src/it/plugin-report/pom.xml
index 34d88a6..ec1d1b8 100644
--- a/maven-plugin-plugin/src/it/plugin-report/pom.xml
+++ b/maven-plugin-plugin/src/it/plugin-report/pom.xml
@@ -42,6 +42,16 @@ under the License.
maven-plugin-api
2.0
+
+ org.apache.maven.reporting
+ maven-reporting-impl
+ 2.0.5
+
+
+ org.apache.maven.reporting
+ maven-reporting-api
+ 3.0
+
diff --git a/maven-plugin-plugin/src/it/plugin-report/src/main/java/org/DummyReport.java b/maven-plugin-plugin/src/it/plugin-report/src/main/java/org/DummyReport.java
new file mode 100644
index 0000000..302314d
--- /dev/null
+++ b/maven-plugin-plugin/src/it/plugin-report/src/main/java/org/DummyReport.java
@@ -0,0 +1,210 @@
+package org;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.siterenderer.Renderer;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.AbstractMavenReport;
+import org.apache.maven.reporting.AbstractMavenReportRenderer;
+import org.apache.maven.reporting.MavenReportException;
+
+/**
+ * Dummy Reporting Plugin.
+ *
+ * @goal report
+ * @requiresReports true
+ * @execute phase="compile"
+ */
+public class DummyReport
+ extends AbstractMavenReport
+{
+ /**
+ * Report output directory.
+ *
+ * @parameter default-value="${project.build.directory}/generated-site/xdoc"
+ */
+ private File outputDirectory;
+
+ /**
+ * Doxia Site Renderer.
+ *
+ * @component
+ */
+ private Renderer siteRenderer;
+
+ /**
+ * The Maven Project.
+ *
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
+ */
+ private MavenProject project;
+
+
+ /**
+ * The goal prefix that will appear before the ":".
+ *
+ * @parameter expression="${goalPrefix}"
+ * @since 2.4
+ */
+ protected String goalPrefix;
+
+ /**
+ * Set this to "true" to skip invoking any goals or reports of the plugin.
+ *
+ * @parameter default-value="false" expression="${maven.plugin.skip}"
+ * @since 2.8
+ */
+ private boolean skip;
+
+ /**
+ * Set this to "true" to skip generating the report.
+ *
+ * @parameter default-value="false" expression="${maven.plugin.report.skip}"
+ * @since 2.8
+ */
+ private boolean skipReport;
+
+ /** {@inheritDoc} */
+ protected Renderer getSiteRenderer()
+ {
+ return siteRenderer;
+ }
+
+ /** {@inheritDoc} */
+ protected String getOutputDirectory()
+ {
+ return outputDirectory.getPath();
+ }
+
+ /** {@inheritDoc} */
+ protected MavenProject getProject()
+ {
+ return project;
+ }
+
+ /** {@inheritDoc} */
+ public boolean canGenerateReport()
+ {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ protected void executeReport( Locale locale )
+ throws MavenReportException
+ {
+ if ( !canGenerateReport() )
+ {
+ return;
+ }
+ if (skip || skipReport)
+ {
+ getLog().info( "Maven Plugin Plugin Report generation skipped." );
+ return;
+ }
+
+ // Generate the plugin's documentation
+ generatePluginDocumentation( locale );
+ }
+
+ /** {@inheritDoc} */
+ public String getDescription( Locale locale )
+ {
+ return getBundle( locale ).getString( "report.plugin.description" );
+ }
+
+ /** {@inheritDoc} */
+ public String getName( Locale locale )
+ {
+ return getBundle( locale ).getString( "report.plugin.name" );
+ }
+
+ /** {@inheritDoc} */
+ public String getOutputName()
+ {
+ return "plugin-info";
+ }
+
+ /**
+ * @param pluginDescriptor not null
+ * @param locale not null
+ * @throws MavenReportException if any
+ */
+ private void generatePluginDocumentation( Locale locale )
+ throws MavenReportException
+ {
+ File outputDir = new File( getOutputDirectory() );
+ outputDir.mkdirs();
+ PluginOverviewRenderer r = new PluginOverviewRenderer( getSink(), locale );
+ r.render();
+ }
+
+ /**
+ * @param locale not null
+ * @return the bundle for this report
+ */
+ protected static ResourceBundle getBundle( Locale locale )
+ {
+ return ResourceBundle.getBundle( "plugin-report", locale, DummyReport.class.getClassLoader() );
+ }
+
+ /**
+ * Generates an overview page with the list of goals
+ * and a link to the goal's page.
+ */
+ static class PluginOverviewRenderer
+ extends AbstractMavenReportRenderer
+ {
+ private final Locale locale;
+
+ /**
+ * @param project not null
+ * @param sink not null
+ * @param locale not null
+ */
+ public PluginOverviewRenderer( Sink sink,
+ Locale locale )
+ {
+ super( sink );
+
+ this.locale = locale;
+ }
+
+ /** {@inheritDoc} */
+ public String getTitle()
+ {
+ return getBundle( locale ).getString( "report.plugin.title" );
+ }
+
+ /** {@inheritDoc} */
+ public void renderBody()
+ {
+ startSection( getTitle() );
+ paragraph( "This is a report." );
+ endSection();
+ }
+ }
+}
diff --git a/maven-plugin-plugin/src/it/plugin-report/src/main/java/org/MyMojo.java b/maven-plugin-plugin/src/it/plugin-report/src/main/java/org/MyMojo.java
index eefc48a..6b8b686 100644
--- a/maven-plugin-plugin/src/it/plugin-report/src/main/java/org/MyMojo.java
+++ b/maven-plugin-plugin/src/it/plugin-report/src/main/java/org/MyMojo.java
@@ -46,6 +46,7 @@ public class MyMojo
* @parameter
* @required
*/
+ @SuppressWarnings( "unused" )
private String required;
/**
@@ -55,6 +56,7 @@ public class MyMojo
* @deprecated Just testing.
* @since 1.1
*/
+ @SuppressWarnings( "unused" )
private String string;
public void execute()
diff --git a/maven-plugin-plugin/src/it/plugin-report/verify.bsh b/maven-plugin-plugin/src/it/plugin-report/verify.bsh
index 7c14d82..14c2756 100644
--- a/maven-plugin-plugin/src/it/plugin-report/verify.bsh
+++ b/maven-plugin-plugin/src/it/plugin-report/verify.bsh
@@ -14,7 +14,8 @@ try
String[] expectedFiles = {
"noop-mojo.html",
- "plugin-info.html",
+ "noop-mojo.html",
+ "report-mojo.html",
};
for ( String path : expectedFiles )
{
diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
index 8b75539..9fdb3cf 100644
--- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
@@ -337,6 +337,7 @@ public class PluginReport
}
/** {@inheritDoc} */
+ @SuppressWarnings( { "unchecked", "rawtypes" } )
public void renderBody()
{
startSection( getTitle() );
@@ -352,8 +353,7 @@ public class PluginReport
boolean hasMavenReport = false;
- for ( @SuppressWarnings( "unchecked" )
- Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
+ for ( Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
{
MojoDescriptor mojo = i.next();
@@ -626,6 +626,7 @@ public class PluginReport
* @param pluginsAsMap could be null
* @return the value of the target in the configuration of maven-compiler-plugin.
*/
+ @SuppressWarnings( "rawtypes" )
private static String discoverJdkRequirementFromPlugins( Map pluginsAsMap )
{
if ( pluginsAsMap == null )
diff --git a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
index b39bad1..899d70e 100644
--- a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
+++ b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
@@ -273,6 +273,18 @@ public class PluginXdocGenerator
w.writeMarkup( getString( "pluginxdoc.mojodescriptor.projectRequired" ) );
w.endElement(); //li
}
+
+ if ( mojoDescriptor.isRequiresReports() )
+ {
+ if ( !addedUl )
+ {
+ w.startElement( "ul" );
+ addedUl = true;
+ }
+ w.startElement( "li" );
+ w.writeMarkup( getString( "pluginxdoc.mojodescriptor.reportingMojo" ) );
+ w.endElement(); // li
+ }
if ( mojoDescriptor.isAggregator() )
{
diff --git a/maven-plugin-tools-api/src/main/resources/pluginxdoc.properties b/maven-plugin-tools-api/src/main/resources/pluginxdoc.properties
index e84a9ed..4543334 100644
--- a/maven-plugin-tools-api/src/main/resources/pluginxdoc.properties
+++ b/maven-plugin-tools-api/src/main/resources/pluginxdoc.properties
@@ -29,6 +29,7 @@ pluginxdoc.mojodescriptor.deprecated=This plugin goal has been deprecate
pluginxdoc.mojodescriptor.projectRequired=Requires a Maven project to be executed.
pluginxdoc.mojodescriptor.aggregator=Executes as an aggregator plugin.
pluginxdoc.mojodescriptor.directInvocationOnly=Executes by direct invocation only.
+pluginxdoc.mojodescriptor.reportingMojo=Executes as a reportSet (reporting goal).
pluginxdoc.mojodescriptor.dependencyResolutionRequired=Requires dependency resolution of artifacts in scope: {0}.
pluginxdoc.mojodescriptor.dependencyCollectionRequired=Requires dependency collection of artifacts in scope: {0}.
pluginxdoc.mojodescriptor.since=Since version: {0}.
diff --git a/maven-plugin-tools-api/src/main/resources/pluginxdoc_fr.properties b/maven-plugin-tools-api/src/main/resources/pluginxdoc_fr.properties
index 0fa8263..b5237fb 100644
--- a/maven-plugin-tools-api/src/main/resources/pluginxdoc_fr.properties
+++ b/maven-plugin-tools-api/src/main/resources/pluginxdoc_fr.properties
@@ -29,6 +29,7 @@ pluginxdoc.mojodescriptor.deprecated=Le goal de ce plugin goal est obsol
pluginxdoc.mojodescriptor.projectRequired=Exige un projet Maven pour \u00eatre ex\u00e9cut\u00e9.
pluginxdoc.mojodescriptor.aggregator=S'ex\u00e9cute comme un plugin agr\u00e9g\u00e9.
pluginxdoc.mojodescriptor.directInvocationOnly=S'ex\u00e9cute par l'invocation directe seulement.
+pluginxdoc.mojodescriptor.reportingMojo=S'ex\u00e9cute comme un reportSet (goal de reportage).
pluginxdoc.mojodescriptor.dependencyResolutionRequired=Exige une r\u00e9solution de d\u00e9pendances des artefacts dans le scope : {0}.
pluginxdoc.mojodescriptor.dependencyCollectionRequired=Exige une collection de d\u00e9pendances des artefacts dans le scope : {0}.
pluginxdoc.mojodescriptor.since=Depuis la version : {0}.