diff --git a/maven-plugin-report-plugin/src/it/plugin-report-400/invoker.properties b/maven-plugin-report-plugin/src/it/plugin-report-400/invoker.properties
new file mode 100644
index 000000000..5cc536a2e
--- /dev/null
+++ b/maven-plugin-report-plugin/src/it/plugin-report-400/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.goals = clean site
diff --git a/maven-plugin-report-plugin/src/it/plugin-report-400/pom.xml b/maven-plugin-report-plugin/src/it/plugin-report-400/pom.xml
new file mode 100644
index 000000000..6961416e6
--- /dev/null
+++ b/maven-plugin-report-plugin/src/it/plugin-report-400/pom.xml
@@ -0,0 +1,141 @@
+
+
+
+
+
+ 4.0.0
+
+ org.apache.maven.its
+ plugin-report
+ 1.0-SNAPSHOT
+ maven-plugin
+
+ MPLUGIN-105
+
+ Test basic site generation to guard against regression.
+
+
+
+ UTF-8
+
+
+
+
+ org.apache.maven
+ maven-plugin-api
+ @maven4Version@
+ provided
+
+
+ org.apache.maven
+ maven-artifact
+ @maven4Version@
+ provided
+
+
+ org.apache.maven
+ maven-core
+ @maven4Version@
+ provided
+
+
+ org.apache.maven.reporting
+ maven-reporting-api
+ @reportingApiVersion@
+
+
+ org.apache.maven.reporting
+ maven-reporting-impl
+ @reportingImplVersion@
+
+
+ org.apache.maven.plugin-tools
+ maven-plugin-annotations
+ @project.version@
+ compile
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ @version.maven-compiler-plugin@
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-plugin-plugin
+ @project.version@
+
+ true
+ prefix
+
+
+
+ mojo-descriptor
+
+ descriptor
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-site-plugin
+ @sitePluginVersion@
+
+
+
+
+
+ true
+
+
+ org.apache.maven.plugins
+ maven-project-info-reports-plugin
+ @projectInfoReportsPlugin@
+
+
+
+ index
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-plugin-report-plugin
+ @project.version@
+
+
+
+ report
+
+
+
+
+
+
+
diff --git a/maven-plugin-report-plugin/src/it/plugin-report-400/src/main/java/org/DummyReport.java b/maven-plugin-report-plugin/src/it/plugin-report-400/src/main/java/org/DummyReport.java
new file mode 100644
index 000000000..1ac5ad709
--- /dev/null
+++ b/maven-plugin-report-plugin/src/it/plugin-report-400/src/main/java/org/DummyReport.java
@@ -0,0 +1,199 @@
+/*
+ * 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.
+ */
+package org;
+
+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.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+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.
+ */
+@Mojo(name = "report", requiresReports = true)
+@Execute(phase = LifecyclePhase.COMPILE)
+public class DummyReport extends AbstractMavenReport {
+ /**
+ * Report output directory.
+ */
+ @Parameter(defaultValue = "${project.build.directory}/generated-site/xdoc")
+ private File outputDirectory;
+
+ /**
+ * Doxia Site Renderer.
+ */
+ @Component
+ private Renderer siteRenderer;
+
+ /**
+ * The Maven Project.
+ */
+ @Parameter(property = "project", readonly = true, required = true)
+ private MavenProject project;
+
+ /**
+ * The goal prefix that will appear before the ":".
+ *
+ * @since 2.4
+ */
+ @Parameter(property = "goalPrefix")
+ protected String goalPrefix;
+
+ /**
+ * Set this to "true" to skip invoking any goals or reports of the plugin.
+ *
+ * @since 2.8
+ */
+ @Parameter(defaultValue = "false", property = "maven.plugin.skip")
+ private boolean skip;
+
+ /**
+ * Set this to "true" to skip generating the report.
+ *
+ * @since 2.8
+ */
+ @Parameter(defaultValue = "false", property = "maven.plugin.report.skip")
+ 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() {
+ if (skip || skipReport) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void executeReport(Locale locale) throws MavenReportException {
+ // 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 sink not null
+ * @param locale not null
+ */
+ PluginOverviewRenderer(Sink sink, Locale locale) {
+ super(sink);
+
+ this.locale = locale;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getTitle() {
+ return getBundle(locale).getString("report.plugin.title");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void renderBody() {
+ startSection(getTitle());
+ paragraph("This is a report.");
+ endSection();
+ }
+ }
+}
diff --git a/maven-plugin-report-plugin/src/it/plugin-report-400/src/main/java/org/MyMojo.java b/maven-plugin-report-plugin/src/it/plugin-report-400/src/main/java/org/MyMojo.java
new file mode 100644
index 000000000..d2f2e77f9
--- /dev/null
+++ b/maven-plugin-report-plugin/src/it/plugin-report-400/src/main/java/org/MyMojo.java
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+package org;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+
+/**
+ * Does nothing.
+ *
+ * @since 1.0
+ * @deprecated You don't use test goals, do you?
+ */
+@Mojo(
+ name = "noop",
+ defaultPhase = LifecyclePhase.PROCESS_SOURCES,
+ requiresDependencyResolution = ResolutionScope.TEST,
+ requiresDirectInvocation = true,
+ requiresOnline = true,
+ inheritByDefault = false,
+ aggregator = true)
+@Execute(phase = LifecyclePhase.COMPILE)
+public class MyMojo extends AbstractMojo {
+
+ /**
+ * This is a test.
+ */
+ @SuppressWarnings("unused")
+ @Parameter(required = true)
+ private String required;
+
+ /**
+ * This is a test.
+ *
+ * @since 1.1
+ * @deprecated Just testing.
+ */
+ @SuppressWarnings("unused")
+ @Parameter(property = "string", defaultValue = "${project.version}/")
+ private String string;
+
+ public void execute() {
+ // intentional do nothing
+ }
+}
diff --git a/maven-plugin-report-plugin/src/it/plugin-report-400/verify.groovy b/maven-plugin-report-plugin/src/it/plugin-report-400/verify.groovy
new file mode 100644
index 000000000..18fbfbbd3
--- /dev/null
+++ b/maven-plugin-report-plugin/src/it/plugin-report-400/verify.groovy
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+assert new File( basedir, 'target/site/noop-mojo.html' ).isFile()
+assert new File( basedir, 'target/site/report-mojo.html' ).isFile()
+
+def pluginInfo = new File( basedir, 'target/site/plugin-info.html' )
+assert pluginInfo.isFile()
+
+assert !pluginInfo.text.contains('Memory')
+assert !pluginInfo.text.contains('Disk Space')
+// check JDK and Maven requirements
+assert pluginInfo.text.contains('2.0.0')
+assert pluginInfo.text.contains(maven4Version)
+
+// deprecated info and description
+assert pluginInfo.text.contains('Deprecated. You don\'t use test goals, do you?
')
+assert pluginInfo.text.contains('Does nothing.')
+
+
+def noopMojo = new File( basedir, 'target/site/noop-mojo.html' )
+assert noopMojo.isFile()
+
+// deprecated in table and details
+assert noopMojo.text.count('Deprecated.
Just testing.
') == 2
+
+def reportMojo = new File( basedir, 'target/site/report-mojo.html' )
+assert reportMojo.isFile()
+
+assert reportMojo.text.contains('Report output directory. Default: ${project.build.directory}/generated-site/xdoc | ')
+
diff --git a/maven-plugin-report-plugin/src/it/plugin-report/verify.groovy b/maven-plugin-report-plugin/src/it/plugin-report/verify.groovy
index ea819a144..d5b64b276 100644
--- a/maven-plugin-report-plugin/src/it/plugin-report/verify.groovy
+++ b/maven-plugin-report-plugin/src/it/plugin-report/verify.groovy
@@ -40,3 +40,7 @@ assert noopMojo.isFile()
// deprecated in table and details
assert noopMojo.text.count('Deprecated.
Just testing.
') == 2
+def reportMojo = new File( basedir, 'target/site/report-mojo.html' )
+assert reportMojo.isFile()
+
+assert reportMojo.text.contains('Report output directory. Default: ${project.build.directory}/generated-site/xdoc | ')
diff --git a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/PluginDescriptorBuilder.java b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/PluginDescriptorBuilder.java
index 037fdf6fd..8d2742450 100644
--- a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/PluginDescriptorBuilder.java
+++ b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/PluginDescriptorBuilder.java
@@ -40,6 +40,9 @@
* @author Jason van Zyl
*/
public class PluginDescriptorBuilder {
+
+ boolean isV4;
+
public PluginDescriptor build(Reader reader) throws PlexusConfigurationException {
return build(reader, null);
}
@@ -70,6 +73,11 @@ public PluginDescriptor build(Reader reader, String source) throws PlexusConfigu
pluginDescriptor.setInheritedByDefault(Boolean.parseBoolean(inheritedByDefault));
}
+ String requiredMavenVersion = c.getChild("requiredMavenVersion").getValue();
+ if (requiredMavenVersion != null) {
+ isV4 = requiredMavenVersion.startsWith("4");
+ }
+
// ----------------------------------------------------------------------
// Components
// ----------------------------------------------------------------------
@@ -277,10 +285,15 @@ public MojoDescriptor buildComponentDescriptor(PlexusConfiguration c, PluginDesc
parameter.setSince(d.getChild("since").getValue());
- PlexusConfiguration paramConfig = mojoConfig.getChild(parameter.getName(), false);
- if (paramConfig != null) {
- parameter.setExpression(paramConfig.getValue(null));
- parameter.setDefaultValue(paramConfig.getAttribute("default-value"));
+ if (isV4) {
+ parameter.setExpression(d.getChild("expression").getValue());
+ parameter.setDefaultValue(d.getChild("defaultValue").getValue());
+ } else {
+ PlexusConfiguration paramConfig = mojoConfig.getChild(parameter.getName(), false);
+ if (paramConfig != null) {
+ parameter.setExpression(paramConfig.getValue(null));
+ parameter.setDefaultValue(paramConfig.getAttribute("default-value"));
+ }
}
parameters.add(parameter);