diff --git a/maven-plugin-plugin/src/site/markdown/index.md b/maven-plugin-plugin/src/site/markdown/index.md index 0ea1f957b..e56b67cd7 100644 --- a/maven-plugin-plugin/src/site/markdown/index.md +++ b/maven-plugin-plugin/src/site/markdown/index.md @@ -32,10 +32,10 @@ The Maven Plugin Plugin is used to create a [Maven plugin descriptor](/ref/curre The Plugin Plugin has four goals: -- [plugin:descriptor](./descriptor-mojo.html) generates a plugin descriptor, -- [plugin:addPluginArtifactMetadata](./addPluginArtifactMetadata-mojo.html) injects any plugin-specific artifact metadata to the project's artifact, for subsequent installation and deployment, -- [plugin:helpmojo](./helpmojo-mojo.html) generates a help mojo which describes all mojos in a plugin, -- [plugin:help](./help-mojo.html) display help information on maven-plugin-plugin. +- [plugin:descriptor](./descriptor-goal.html) generates a plugin descriptor, +- [plugin:addPluginArtifactMetadata](./addPluginArtifactMetadata-goal.html) injects any plugin-specific artifact metadata to the project's artifact, for subsequent installation and deployment, +- [plugin:helpmojo](./helpmojo-goal.html) generates a help mojo which describes all mojos in a plugin, +- [plugin:help](./help-goal.html) display help information on maven-plugin-plugin. ## Usage General instructions on how to use the Plugin Plugin can be found on the [usage page](./usage.html). Some more specific use cases are described in the examples given below. Last but not least, users occasionally contribute additional examples, tips or errata to the [Plugin Developers Centre page](https://maven.apache.org/plugin-developers/index.html). diff --git a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/verify.groovy b/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/verify.groovy index 62a67dbbb..6cbdb870c 100644 --- a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/verify.groovy +++ b/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/verify.groovy @@ -17,7 +17,7 @@ * under the License. */ -File touchFile = new File( basedir, "javasample-maven-plugin/target/site/touch-mojo.html" ) +File touchFile = new File( basedir, "javasample-maven-plugin/target/site/touch-goal.html" ) assert touchFile.exists() assert touchFile.isFile() content = touchFile.text diff --git a/maven-plugin-report-plugin/src/it/mplugin-191/verify.groovy b/maven-plugin-report-plugin/src/it/mplugin-191/verify.groovy index 24506b919..3647b22d7 100644 --- a/maven-plugin-report-plugin/src/it/mplugin-191/verify.groovy +++ b/maven-plugin-report-plugin/src/it/mplugin-191/verify.groovy @@ -18,7 +18,7 @@ File pluginInfo = new File( basedir, "target/site/plugin-info.html" ); assert pluginInfo.isFile() -File touchMojo = new File( basedir, "target/site/touch-mojo.html" ); +File touchMojo = new File( basedir, "target/site/touch-goal.html" ); assert touchMojo.isFile() return true; diff --git a/maven-plugin-report-plugin/src/it/mplugin-319_report-since/verify.groovy b/maven-plugin-report-plugin/src/it/mplugin-319_report-since/verify.groovy index 877d8f83b..011e4757f 100644 --- a/maven-plugin-report-plugin/src/it/mplugin-319_report-since/verify.groovy +++ b/maven-plugin-report-plugin/src/it/mplugin-319_report-since/verify.groovy @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -assert new File( basedir, 'target/site/noop-mojo.html' ).exists() +assert new File( basedir, 'target/site/noop-goal.html' ).exists() -content = new File( basedir, 'target/site/noop-mojo.html' ).text +content = new File( basedir, 'target/site/noop-goal.html' ).text assert content.contains( '
  • Since version: 1.0.
  • ' ) assert content.contains( '-' ) diff --git a/maven-plugin-report-plugin/src/it/mplugin-394_report-encoding/verify.groovy b/maven-plugin-report-plugin/src/it/mplugin-394_report-encoding/verify.groovy index e10b63081..b4f10e2d0 100644 --- a/maven-plugin-report-plugin/src/it/mplugin-394_report-encoding/verify.groovy +++ b/maven-plugin-report-plugin/src/it/mplugin-394_report-encoding/verify.groovy @@ -17,7 +17,7 @@ * under the License. */ -generated = new File( basedir, "target/site/test-mojo.html").getText("UTF-8") +generated = new File( basedir, "target/site/test-goal.html").getText("UTF-8") assert generated.contains("Mojo-Description with some non-ASCII characters: €àáâãäåæòóôõöø") assert generated.contains("Parameter-Description with some non-ASCII characters: ÈÉÊË€") diff --git a/maven-plugin-report-plugin/src/it/plugin-no-fork-report/verify.groovy b/maven-plugin-report-plugin/src/it/plugin-no-fork-report/verify.groovy index d7d173b27..777601256 100644 --- a/maven-plugin-report-plugin/src/it/plugin-no-fork-report/verify.groovy +++ b/maven-plugin-report-plugin/src/it/plugin-no-fork-report/verify.groovy @@ -17,8 +17,8 @@ * under the License. */ -assert new File( basedir, 'target/site/noop-mojo.html' ).isFile() -assert new File( basedir, 'target/site/report-mojo.html' ).isFile() +assert new File( basedir, 'target/site/noop-goal.html' ).isFile() +assert new File( basedir, 'target/site/report-goal.html' ).isFile() def pluginInfo = new File( basedir, 'target/site/plugin-info.html' ) assert pluginInfo.isFile() @@ -34,7 +34,7 @@ assert pluginInfo.text.contains('
    Deprecated. You don\'t us assert pluginInfo.text.contains('Does nothing.') -def noopMojo = new File( basedir, 'target/site/noop-mojo.html' ) +def noopMojo = new File( basedir, 'target/site/noop-goal.html' ) assert noopMojo.isFile() // deprecated in table and details 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 index a0f1c424a..1f18f04f7 100644 --- a/maven-plugin-report-plugin/src/it/plugin-report-400/verify.groovy +++ b/maven-plugin-report-plugin/src/it/plugin-report-400/verify.groovy @@ -17,8 +17,10 @@ * under the License. */ -assert new File( basedir, 'target/site/noop-mojo.html' ).isFile() -assert new File( basedir, 'target/site/report-mojo.html' ).isFile() +assert new File( basedir, 'target/site/noop-goal.html' ).isFile() +assert new File( basedir, 'target/site/report-goal.html' ).isFile() +assert new File( basedir, 'target/site/noop-mojo.html' ).text.contains( 'noop-goal.html' ) +assert new File( basedir, 'target/site/report-mojo.html' ).text.contains( 'report-goal.html' ) def pluginInfo = new File( basedir, 'target/site/plugin-info.html' ) assert pluginInfo.isFile() @@ -34,13 +36,13 @@ assert pluginInfo.text.contains('
    Deprecated. You don\'t us assert pluginInfo.text.contains('Does nothing.') -def noopMojo = new File( basedir, 'target/site/noop-mojo.html' ) +def noopMojo = new File( basedir, 'target/site/noop-goal.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' ) +def reportMojo = new File( basedir, 'target/site/report-goal.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-detect-requirements-history/verify.groovy b/maven-plugin-report-plugin/src/it/plugin-report-detect-requirements-history/verify.groovy index f1ce27a1a..fe6158f04 100644 --- a/maven-plugin-report-plugin/src/it/plugin-report-detect-requirements-history/verify.groovy +++ b/maven-plugin-report-plugin/src/it/plugin-report-detect-requirements-history/verify.groovy @@ -17,7 +17,7 @@ * under the License. */ -assert new File( basedir, 'target/site/noop-mojo.html' ).isFile() +assert new File( basedir, 'target/site/noop-goal.html' ).isFile() def pluginInfo = new File( basedir, 'target/site/plugin-info.html' ) assert pluginInfo.isFile() diff --git a/maven-plugin-report-plugin/src/it/plugin-report-requirements-history/verify.groovy b/maven-plugin-report-plugin/src/it/plugin-report-requirements-history/verify.groovy index d573e5e65..e7da231a6 100644 --- a/maven-plugin-report-plugin/src/it/plugin-report-requirements-history/verify.groovy +++ b/maven-plugin-report-plugin/src/it/plugin-report-requirements-history/verify.groovy @@ -17,7 +17,7 @@ * under the License. */ -assert new File( basedir, 'target/site/noop-mojo.html' ).isFile() +assert new File( basedir, 'target/site/noop-goal.html' ).isFile() def pluginInfo = new File( basedir, 'target/site/plugin-info.html' ) assert pluginInfo.isFile() diff --git a/maven-plugin-report-plugin/src/it/plugin-report-with-javadoc-links/verify.groovy b/maven-plugin-report-plugin/src/it/plugin-report-with-javadoc-links/verify.groovy index 158ea3e8d..e470fb64d 100644 --- a/maven-plugin-report-plugin/src/it/plugin-report-with-javadoc-links/verify.groovy +++ b/maven-plugin-report-plugin/src/it/plugin-report-with-javadoc-links/verify.groovy @@ -17,7 +17,7 @@ * under the License. */ -def mojoDoc = new File( basedir, 'target/site/test-mojo.html' ) +def mojoDoc = new File( basedir, 'target/site/test-goal.html' ) assert mojoDoc.isFile() 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 d5b64b276..f1782230e 100644 --- a/maven-plugin-report-plugin/src/it/plugin-report/verify.groovy +++ b/maven-plugin-report-plugin/src/it/plugin-report/verify.groovy @@ -17,8 +17,10 @@ * under the License. */ -assert new File( basedir, 'target/site/noop-mojo.html' ).isFile() -assert new File( basedir, 'target/site/report-mojo.html' ).isFile() +assert new File( basedir, 'target/site/noop-goal.html' ).isFile() +assert new File( basedir, 'target/site/report-goal.html' ).isFile() +assert new File( basedir, 'target/site/noop-mojo.html' ).text.contains( 'noop-goal.html' ) +assert new File( basedir, 'target/site/report-mojo.html' ).text.contains( 'report-goal.html' ) def pluginInfo = new File( basedir, 'target/site/plugin-info.html' ) assert pluginInfo.isFile() @@ -34,13 +36,13 @@ assert pluginInfo.text.contains('
    Deprecated. You don\'t us assert pluginInfo.text.contains('Does nothing.') -def noopMojo = new File( basedir, 'target/site/noop-mojo.html' ) +def noopMojo = new File( basedir, 'target/site/noop-goal.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' ) +def reportMojo = new File( basedir, 'target/site/report-goal.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/plugin/plugin/report/PluginNoForkReport.java b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginNoForkReport.java index 1117639ac..ad2752223 100644 --- a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginNoForkReport.java +++ b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginNoForkReport.java @@ -31,8 +31,8 @@ /** * Generates the plugin's report: the plugin details page at plugin-info.html, - * and one goal-mojo.html per goal. - * Relies on one output file from plugin:descriptor. + * and one goal-goal.html per goal. + * Relies on one output file from plugin:descriptor. * * @since 3.14.0 */ diff --git a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginOverviewRenderer.java b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginOverviewRenderer.java index 9b810ca15..6c5aea473 100644 --- a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginOverviewRenderer.java +++ b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginOverviewRenderer.java @@ -130,7 +130,7 @@ private void renderGoalsSection(boolean hasMavenReport) { * Added ./ to define a relative path * @see AbstractMavenReportRenderer#getValidHref(java.lang.String) */ - String goalDocumentationLink = "./" + mojo.getGoal() + "-mojo.html"; + String goalDocumentationLink = "./" + mojo.getGoal() + "-goal.html"; sink.tableCell(); link(goalDocumentationLink, goalName); sink.tableCell_(); diff --git a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginReport.java b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginReport.java index ac1ccdcb5..59e23db2b 100644 --- a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginReport.java +++ b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginReport.java @@ -23,6 +23,7 @@ import java.io.File; import java.io.IOException; import java.io.Reader; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.ArrayList; import java.util.Collections; @@ -63,8 +64,8 @@ /** * Generates the plugin's report: the plugin details page at plugin-info.html - * and one goal-mojo.html per goal. - * Relies on one output file from plugin:descriptor. + * and one goal-goal.html per goal. + * Relies on one output file from plugin:descriptor. * * @author Stephane Nicoll * @author Vincent Siveton @@ -82,6 +83,14 @@ public class PluginReport extends AbstractMavenReport { @Parameter(defaultValue = "false", property = "maven.plugin.report.skip") private boolean skip; + /** + * Set this to {@code false} to stop generating compatibility pages using the legacy {@code -mojo.html} suffix. + * + * @since 4.0.0 + */ + @Parameter(defaultValue = "true", property = "maven.plugin.report.generateLegacyMojoReports") + private boolean generateLegacyMojoReports; + /** * Set this to "true" to generate the usage section for "plugin-info.html" with * {@code true}. @@ -293,9 +302,9 @@ private void generateMojosDocumentation(PluginDescriptor pluginDescriptor, Local throws MavenReportException { if (pluginDescriptor.getMojos() != null) { for (MojoDescriptor descriptor : pluginDescriptor.getMojos()) { + String filename = descriptor.getGoal() + "-goal.html"; GoalRenderer renderer; try { - String filename = descriptor.getGoal() + "-mojo.html"; Sink sink = getSinkFactory().createSink(getReportOutputDirectory(), filename); renderer = new GoalRenderer( sink, @@ -310,10 +319,33 @@ private void generateMojosDocumentation(PluginDescriptor pluginDescriptor, Local throw new MavenReportException("Cannot generate sink for mojo " + descriptor.getGoal(), e); } renderer.render(); + if (generateLegacyMojoReports) { + writeLegacyMojoRedirect(descriptor.getGoal(), filename); + } } } } + private void writeLegacyMojoRedirect(String goal, String filename) throws MavenReportException { + String redirect = "\n" + + "

    This page moved to " + + filename + + ".

    \n"; + try { + Files.write( + new File(getReportOutputDirectory(), goal + "-mojo.html").toPath(), + redirect.getBytes(StandardCharsets.UTF_8)); + } catch (IOException e) { + throw new MavenReportException("Cannot generate legacy page for goal " + goal, e); + } + } + private List discoverVersions(String range) throws VersionRangeResolutionException { MavenProject currentProject = mavenSession.getCurrentProject(); VersionRangeRequest rangeRequest = new VersionRangeRequest(); diff --git a/maven-plugin-report-plugin/src/site/markdown/index.md b/maven-plugin-report-plugin/src/site/markdown/index.md index 0b19f556d..793f7a203 100644 --- a/maven-plugin-report-plugin/src/site/markdown/index.md +++ b/maven-plugin-report-plugin/src/site/markdown/index.md @@ -32,8 +32,8 @@ The Maven Plugin Report Plugin is used to create report files for the Mojos. The Plugin Report Plugin has two goals: -- [plugin-report:report](./report-mojo.html) which generates the plugin documentation: one overview report and documentation for each plugin's goal (mojo). -- [plugin-report:report-no-fork](./report-no-fork-mojo.html) which generates the plugin documentation: one overview report and documentation for each plugin's goal (mojo) without forking the `process-classes` phase again. Note that this goal does require generation of classes before site generation, e.g. by invoking `mvn clean verify site`. +- [plugin-report:report](./report-goal.html) which generates the plugin documentation: one overview report and documentation for each plugin's goal (mojo). +- [plugin-report:report-no-fork](./report-no-fork-goal.html) which generates the plugin documentation: one overview report and documentation for each plugin's goal (mojo) without forking the `process-classes` phase again. Note that this goal does require generation of classes before site generation, e.g. by invoking `mvn clean verify site`. ## Usage General instructions on how to use the Plugin Report Plugin can be found on the [usage page](./usage.html). diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/converter/JavaClassConverterContext.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/converter/JavaClassConverterContext.java index bc6bf04f5..13ece5ffe 100644 --- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/converter/JavaClassConverterContext.java +++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/converter/JavaClassConverterContext.java @@ -148,7 +148,7 @@ public URI getUrl(FullyQualifiedJavadocReference reference) { // Fields and whole-class references to another Mojo link to that Mojo's page. return new URI( null, - "./" + mojoAnnotatedClass.getMojo().name() + "-mojo.html", + "./" + mojoAnnotatedClass.getMojo().name() + "-goal.html", reference.getMember().orElse(null)); } } diff --git a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/converter/JavaClassConverterContextTest.java b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/converter/JavaClassConverterContextTest.java index 457060c57..984dcbaf2 100644 --- a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/converter/JavaClassConverterContextTest.java +++ b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/converter/JavaClassConverterContextTest.java @@ -236,7 +236,7 @@ void getUrl() throws Exception { // field reference in another mojo assertEquals( - new URI(null, "./other-goal-mojo.html", "field1"), + new URI(null, "./other-goal-goal.html", "field1"), context.getUrl(new FullyQualifiedJavadocReference( currentPackageName, "OtherClass", "field1", MemberType.FIELD, false)));