Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions maven-plugin-plugin/src/site/markdown/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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( '<li>Since version: <code>1.0</code>.</li>' )
assert content.contains( '<td><code>-</code></td>' )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: ÈÉÊË€")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -34,7 +34,7 @@ assert pluginInfo.text.contains('<div><strong>Deprecated.</strong> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Missing redirect assertions (not blocking)

The plugin-report IT now asserts that the legacy -mojo.html redirect files exist and point to the new -goal.html pages (e.g. assert new File(basedir, 'target/site/noop-mojo.html').text.contains('noop-goal.html')). This IT only checks that the new -goal.html files exist but doesn't verify the redirect files are created.

Consider adding similar redirect assertions here for consistency.

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()
Expand All @@ -34,13 +36,13 @@ assert pluginInfo.text.contains('<div><strong>Deprecated.</strong> 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('<div><strong>Deprecated.</strong><br />Just testing.</div><br />') == 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('<td>Report output directory.<br /><strong>Default</strong>: <code>${project.build.directory}/generated-site/xdoc</code></td>')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
10 changes: 6 additions & 4 deletions maven-plugin-report-plugin/src/it/plugin-report/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -34,13 +36,13 @@ assert pluginInfo.text.contains('<div><strong>Deprecated.</strong> 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('<div><strong>Deprecated.</strong><br />Just testing.</div><br />') == 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('<td>Report output directory.<br /><strong>Default</strong>: <code>${project.build.directory}/generated-site/xdoc</code></td>')
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

/**
* Generates the plugin's report: the plugin details page at <code>plugin-info.html</code>,
* and one <code><i>goal</i>-mojo.html</code> per goal.
* Relies on one output file from <a href="../maven-plugin-plugin/descriptor-mojo.html">plugin:descriptor</a>.
* and one <code><i>goal</i>-goal.html</code> per goal.
* Relies on one output file from <a href="../maven-plugin-plugin/descriptor-goal.html">plugin:descriptor</a>.
*
* @since 3.14.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -63,8 +64,8 @@

/**
* Generates the plugin's report: the plugin details page at <code>plugin-info.html</code>
* and one <code><i>goal</i>-mojo.html</code> per goal.
* Relies on one output file from <a href="../maven-plugin-plugin/descriptor-mojo.html">plugin:descriptor</a>.
* and one <code><i>goal</i>-goal.html</code> per goal.
* Relies on one output file from <a href="../maven-plugin-plugin/descriptor-goal.html">plugin:descriptor</a>.
*
* @author <a href="snicoll@apache.org">Stephane Nicoll</a>
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
Expand All @@ -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 <extensions>true</extensions>}.
Expand Down Expand Up @@ -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,
Expand All @@ -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 = "<!DOCTYPE html>\n"
+ "<html><head><meta http-equiv=\"refresh\" content=\"0; URL='"
+ filename
+ "'\"><link rel=\"canonical\" href=\""
+ filename
+ "\"></head><body><p>This page moved to <a href=\""
+ filename
+ "\">"
+ filename
+ "</a>.</p></body></html>\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<Version> discoverVersions(String range) throws VersionRangeResolutionException {
MavenProject currentProject = mavenSession.getCurrentProject();
VersionRangeRequest rangeRequest = new VersionRangeRequest();
Expand Down
4 changes: 2 additions & 2 deletions maven-plugin-report-plugin/src/site/markdown/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));

Expand Down