Skip to content

Commit

Permalink
update IT to use class level annotation instead of javadoc tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mattnelson committed Aug 1, 2024
1 parent 6cceb85 commit acb1b4a
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 65 deletions.
55 changes: 39 additions & 16 deletions maven-plugin-report-plugin/src/it/plugin-no-fork-report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ under the License.

<name>MPLUGIN-529</name>
<description>
Test non-forking goals to guard against regression of MPLUGIN-529.
Test basic site generation to guard against regression.
</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>

<dependencies>
Expand Down Expand Up @@ -67,23 +65,29 @@ under the License.
<artifactId>maven-reporting-impl</artifactId>
<version>@reportingImplVersion@</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>@project.version@</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>@compilerPluginVersion@</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>@compilerPluginVersion@</version>
<configuration>
<!-- old maven-parent, so fix it like this. -->
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>@enforcerPluginVersion@</version>
<executions>
<execution>
<goals>
Expand All @@ -103,22 +107,41 @@ under the License.
<artifactId>maven-plugin-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
<goalPrefix>prefix</goalPrefix>
</configuration>
<executions>
<execution>
<id>mojo-descriptor</id>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>@sitePluginVersion@</version>
<configuration>
<locales>en,de,fr</locales>
</configuration>
</plugin>
</plugins>
</build>

<reporting>
<excludeDefaults>true</excludeDefaults>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>@projectInfoReportsPlugin@</version>
<reportSets>
<reportSet>
<reports>
<report>index</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-report-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,82 +24,88 @@

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.
*
* @goal report
* @requiresReports true
* @execute phase="compile"
*/
@Mojo(name = "report", requiresReports = true)
@Execute(phase = LifecyclePhase.COMPILE)
public class DummyReport extends AbstractMavenReport {
/**
* Report output directory.
*
* @parameter default-value="${project.build.directory}/generated-site/xdoc"
*/
@Parameter(defaultValue = "${project.build.directory}/generated-site/xdoc")
private File outputDirectory;

/**
* Doxia Site Renderer.
*
* @component
*/
@Component
private Renderer siteRenderer;

/**
* The Maven Project.
*
* @parameter expression="${project}"
* @required
* @readonly
*/
@Parameter(property = "project", readonly = true, required = true)
private MavenProject project;

/**
* The goal prefix that will appear before the ":".
*
* @parameter expression="${goalPrefix}"
* @since 2.4
*/
@Parameter(property = "goalPrefix")
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
*/
@Parameter(defaultValue = "false", property = "maven.plugin.skip")
private boolean skip;

/**
* Set this to "true" to skip generating the report.
*
* @parameter default-value="false" expression="${maven.plugin.report.skip}"
* @since 2.8
*/
@Parameter(defaultValue = "false", property = "maven.plugin.report.skip")
private boolean skipReport;

/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
protected Renderer getSiteRenderer() {
return siteRenderer;
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
protected String getOutputDirectory() {
return outputDirectory.getPath();
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
protected MavenProject getProject() {
return project;
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
public boolean canGenerateReport() {
if (skip || skipReport) {
getLog().info("Maven Plugin Plugin Report generation skipped.");
Expand All @@ -109,30 +115,38 @@ public boolean canGenerateReport() {
return true;
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
protected void executeReport(Locale locale) throws MavenReportException {
// Generate the plugin's documentation
generatePluginDocumentation(locale);
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
public String getDescription(Locale locale) {
return getBundle(locale).getString("report.plugin.description");
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
public String getName(Locale locale) {
return getBundle(locale).getString("report.plugin.name");
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
public String getOutputName() {
return "plugin-info";
}

/**
* @param pluginDescriptor not null
* @param locale not null
* @param locale not null
* @throws MavenReportException if any
*/
private void generatePluginDocumentation(Locale locale) throws MavenReportException {
Expand All @@ -158,21 +172,25 @@ static class PluginOverviewRenderer extends AbstractMavenReportRenderer {
private final Locale locale;

/**
* @param sink not null
* @param locale not null
* @param sink not null
* @param locale not null
*/
PluginOverviewRenderer(Sink sink, Locale locale) {
super(sink);

this.locale = locale;
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
public String getTitle() {
return getBundle(locale).getString("report.plugin.title");
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
protected void renderBody() {
startSection(getTitle());
paragraph("This is a report.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,44 @@
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.
*
* @goal noop
* @phase process-sources
* @requiresDependencyResolution test
* @requiresDirectInvocation true
* @requiresOnline
* @inheritByDefault false
* @execute phase="compile"
* @aggregator
* @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.
*
* @parameter
* @required
*/
@SuppressWarnings("unused")
@Parameter(required = true)
private String required;

/**
* This is a test.
*
* @parameter expression="${string}" default-value="${project.version}/</markup-must-be-escaped>"
* @deprecated Just testing.
* @since 1.1
* @deprecated Just testing.
*/
@SuppressWarnings("unused")
@Parameter(property = "string", defaultValue = "${project.version}/</markup-must-be-escaped>")
private String string;

public void execute() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* 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' )
Expand All @@ -32,13 +33,6 @@ assert pluginInfo.text.contains('3.9.8')
assert pluginInfo.text.contains('<div><strong>Deprecated.</strong> You don\'t use test goals, do you?</div><br />')
assert pluginInfo.text.contains('Does nothing.')

assert new File( basedir, 'target/site/de/noop-mojo.html' ).isFile()
assert new File( basedir, 'target/site/de/report-mojo.html' ).isFile()
assert new File( basedir, 'target/site/de/plugin-info.html' ).isFile()

assert new File( basedir, 'target/site/fr/noop-mojo.html' ).isFile()
assert new File( basedir, 'target/site/fr/report-mojo.html' ).isFile()
assert new File( basedir, 'target/site/fr/plugin-info.html' ).isFile()

def noopMojo = new File( basedir, 'target/site/noop-mojo.html' )
assert noopMojo.isFile()
Expand All @@ -47,3 +41,4 @@ assert noopMojo.isFile()
assert noopMojo.text.count('<div><strong>Deprecated.</strong><br />Just testing.</div><br />') == 2

assert 1 == new File( basedir, 'build.log' ).text.count('Always pass!');

1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<compilerPluginVersion>3.11.0</compilerPluginVersion>
<javadocPluginVersion>3.5.0</javadocPluginVersion>
<version.maven-invoker-plugin>3.7.0</version.maven-invoker-plugin>
<enforcerPluginVersion>3.5.0</enforcerPluginVersion>
<project.build.outputTimestamp>2024-06-26T07:46:19Z</project.build.outputTimestamp>
</properties>

Expand Down

0 comments on commit acb1b4a

Please sign in to comment.