Skip to content

Commit

Permalink
[MPMD-349] Upgrade Maven Reporting API to 3.1.1/Maven Reporting Impl …
Browse files Browse the repository at this point in the history
…to 3.2.0

This plugin hasn't been touched testwise for a very long time. The testing
approach from MPIR has been applied to accommodate M-R-Impl 3.2.0 and future
versions of it. The negative effect is that the parameter 'sourceEncoding'
has duplicated 'inputEncoding' from AbstractMavenReport for a long time.
For the sake of consistency it has been replaced with 'inputEncoding' which
breaks backward compatibility. Users are advised to use
${project.build.sourceEncoding} anyway.

This also upgrades for ITs:
* Maven Site Plugin to 3.12.1
* Maven Project Info Reports Plugin to 3.4.1
* Maven JXR Plugin to 3.3.0

This closes #84
  • Loading branch information
michael-o committed Aug 16, 2022
1 parent 1740f00 commit 2b7d2d7
Show file tree
Hide file tree
Showing 65 changed files with 572 additions and 706 deletions.
58 changes: 49 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ under the License.
<javaVersion>8</javaVersion><!-- Because PMD 6.35.0+ requires Java 8 -->
<pmdVersion>6.48.0</pmdVersion>
<slf4jVersion>1.7.36</slf4jVersion>
<sitePluginVersion>3.12.0</sitePluginVersion>
<projectInfoReportsPluginVersion>3.3.0</projectInfoReportsPluginVersion>
<aetherVersion>1.0.0.v20140518</aetherVersion>
<sitePluginVersion>3.12.1</sitePluginVersion>
<projectInfoReportsPluginVersion>3.4.1</projectInfoReportsPluginVersion>
<jxrPluginVersion>3.3.0</jxrPluginVersion>
<project.build.outputTimestamp>2022-05-31T17:37:31Z</project.build.outputTimestamp>
</properties>

Expand Down Expand Up @@ -203,18 +205,24 @@ under the License.
doxia-site-renderer requires transitively dom4j 1.1 which provides a very old version of jaxen (same jar).
PMD requires a newer version of jaxen, which is not compatible.
-->
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- shared -->
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
Expand Down Expand Up @@ -243,11 +251,43 @@ under the License.
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<!-- that's a very old version, but it's the newest one that brings in
a old guava version, that is compatible with maven 3.1.1.
maven 3.1.1 uses guava 11, wiremock 1.49 uses guava 13.0.1
-->
<version>1.49</version>
<version>1.58</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<version>${aetherVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-impl</artifactId>
<version>${aetherVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-connector-basic</artifactId>
<version>${aetherVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-transport-wagon</artifactId>
<version>${aetherVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http-lightweight</artifactId>
<version>3.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion src/it/MPMD-128-xref-link/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
<version>@jxrPluginVersion@</version>
</plugin>
</plugins>
</reporting>
Expand Down
2 changes: 1 addition & 1 deletion src/it/MPMD-172/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.4</version>
<version>@jxrPluginVersion@</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/it/MPMD-253-xref-link-multi-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
<version>@jxrPluginVersion@</version>
</plugin>
</plugins>
</reporting>
Expand Down
1 change: 0 additions & 1 deletion src/it/MPMD-270-325-JDK11/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ under the License.
<failurePriority>4</failurePriority>
<printFailingErrors>true</printFailingErrors>
<targetJdk>${java.version}</targetJdk>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
</configuration>
<executions>
Expand Down
1 change: 0 additions & 1 deletion src/it/MPMD-280-JDK12/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ under the License.
<failurePriority>4</failurePriority>
<printFailingErrors>true</printFailingErrors>
<targetJdk>${java.version}</targetJdk>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
</configuration>
<executions>
Expand Down
5 changes: 4 additions & 1 deletion src/it/MPMD-289-format-html-check/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ under the License.
Then report format is html, xml format should still be created so that the check goal still works.
</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
Expand All @@ -41,7 +45,6 @@ under the License.
<skip>false</skip>
<failOnViolation>true</failOnViolation>
<failurePriority>4</failurePriority>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<skipEmptyReport>false</skipEmptyReport>
<format>html</format>
Expand Down
1 change: 0 additions & 1 deletion src/it/MPMD-295-JDK13/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ under the License.
<failurePriority>4</failurePriority>
<printFailingErrors>true</printFailingErrors>
<targetJdk>${java.version}</targetJdk>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
</configuration>
<executions>
Expand Down
1 change: 0 additions & 1 deletion src/it/MPMD-302-JDK14/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ under the License.
<failurePriority>4</failurePriority>
<printFailingErrors>true</printFailingErrors>
<targetJdk>${java.version}</targetJdk>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
</configuration>
<executions>
Expand Down
1 change: 0 additions & 1 deletion src/it/MPMD-302-JDK15/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ under the License.
<failurePriority>4</failurePriority>
<printFailingErrors>true</printFailingErrors>
<targetJdk>${java.version}</targetJdk>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
</configuration>
<executions>
Expand Down
1 change: 0 additions & 1 deletion src/it/MPMD-304-toolchain-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ under the License.
<failOnViolation>false</failOnViolation>
<printFailingErrors>true</printFailingErrors>
<targetJdk>${java.version}</targetJdk>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>10</minimumTokens>
</configuration>
<executions>
Expand Down
1 change: 0 additions & 1 deletion src/it/MPMD-312-JDK16/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ under the License.
<failurePriority>4</failurePriority>
<printFailingErrors>true</printFailingErrors>
<targetJdk>${java.version}</targetJdk>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
</configuration>
<executions>
Expand Down
1 change: 0 additions & 1 deletion src/it/MPMD-312-JDK17/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ under the License.
<failurePriority>4</failurePriority>
<printFailingErrors>true</printFailingErrors>
<targetJdk>${java.version}</targetJdk>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
</configuration>
<executions>
Expand Down
1 change: 0 additions & 1 deletion src/it/MPMD-332-JDK18/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ under the License.
<failurePriority>4</failurePriority>
<printFailingErrors>true</printFailingErrors>
<targetJdk>${java.version}</targetJdk>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
</configuration>
<executions>
Expand Down
1 change: 0 additions & 1 deletion src/it/MPMD-348-JDK19/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ under the License.
<failurePriority>4</failurePriority>
<printFailingErrors>true</printFailingErrors>
<targetJdk>${java.version}</targetJdk>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
</configuration>
<executions>
Expand Down
1 change: 0 additions & 1 deletion src/it/empty-rulesets/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ under the License.
<failOnViolation>true</failOnViolation>
<failurePriority>4</failurePriority>
<targetJdk>1.7</targetJdk>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<excludes>
<exclude>**/*Bean.java</exclude>
Expand Down
7 changes: 5 additions & 2 deletions src/it/mpmd-168-empty-report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ under the License.
Verify the "skipEmptyReport" parameter.
</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
Expand All @@ -51,7 +55,6 @@ under the License.
<configuration>
<verbose>true</verbose>
<minimumTokens>25</minimumTokens>
<sourceEncoding>UTF-8</sourceEncoding>
<failOnViolation>false</failOnViolation> <!-- force execution of both goals, will be checked with verify-script -->
<skipPmdError>false</skipPmdError>
<!-- <skipEmptyReport>false</skipEmptyReport> skipEmptyReport is false by default since 3.13.0 -->
Expand All @@ -74,7 +77,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
<version>@jxrPluginVersion@</version>
</plugin>
</plugins>
</reporting>
Expand Down
7 changes: 5 additions & 2 deletions src/it/mpmd-168/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ under the License.
Verify the "skipEmptyReport" parameter.
</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
Expand All @@ -51,7 +55,6 @@ under the License.
<configuration>
<verbose>true</verbose>
<minimumTokens>25</minimumTokens>
<sourceEncoding>UTF-8</sourceEncoding>
<failOnViolation>false</failOnViolation> <!-- force execution of both goals, will be checked with verify-script -->
<skipPmdError>false</skipPmdError>
<skipEmptyReport>true</skipEmptyReport>
Expand All @@ -74,7 +77,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
<version>@jxrPluginVersion@</version>
</plugin>
</plugins>
</reporting>
Expand Down
67 changes: 2 additions & 65 deletions src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.apache.maven.toolchain.ToolchainManager;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.PathTool;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;

import net.sourceforge.pmd.PMDVersion;
Expand All @@ -73,14 +72,6 @@ public abstract class AbstractPmdReport
@Parameter( property = "project.build.directory", required = true )
protected File targetDirectory;

/**
* The output directory for the final HTML report. Note that this parameter is only evaluated if the goal is run
* directly from the command line or during the default lifecycle. If the goal is run indirectly as part of a site
* generation, the output directory configured in the Maven Site Plugin is used instead.
*/
@Parameter( property = "project.reporting.outputDirectory", required = true )
protected File outputDirectory;

/**
* Set the output format type, in addition to the HTML report. Must be one of: "none", "csv", "xml", "txt" or the
* full class name of the PMD renderer to use. See the net.sourceforge.pmd.renderers package javadoc for available
Expand Down Expand Up @@ -172,22 +163,6 @@ public abstract class AbstractPmdReport
@Deprecated
protected boolean aggregate;

/**
* The file encoding to use when reading the Java sources.
*
* @since 2.3
*/
@Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
private String sourceEncoding;

/**
* The file encoding when writing non-HTML reports.
*
* @since 2.5
*/
@Parameter( property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}" )
private String outputEncoding;

/**
* Whether to include the xml files generated by PMD/CPD in the site.
*
Expand Down Expand Up @@ -271,12 +246,6 @@ public abstract class AbstractPmdReport
// Read-only parameters
// ----------------------------------------------------------------------

/**
* The project to analyse.
*/
@Parameter( defaultValue = "${project}", readonly = true, required = true )
protected MavenProject project;

/**
* The projects in the reactor for aggregation report.
*/
Expand All @@ -290,12 +259,6 @@ public abstract class AbstractPmdReport
@Parameter( defaultValue = "${session}", required = true, readonly = true )
protected MavenSession session;

/**
* Site rendering component for generating the HTML report.
*/
@Component
private Renderer siteRenderer;

@Component
private ToolchainManager toolchainManager;

Expand Down Expand Up @@ -588,32 +551,6 @@ public boolean canGenerateReport()
return true;
}

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

protected String getSourceEncoding()
{
return sourceEncoding;
}

/**
* Gets the effective reporting output files encoding.
*
* @return The effective reporting output file encoding, never <code>null</code>.
* @since 2.5
*/
@Override
protected String getOutputEncoding()
{
return ( outputEncoding != null ) ? outputEncoding : ReaderFactory.UTF_8;
}

protected String determineCurrentRootLogLevel()
{
String logLevel = System.getProperty( "org.slf4j.simpleLogger.defaultLogLevel" );
Expand Down Expand Up @@ -694,9 +631,9 @@ protected Collection<MavenProject> getAggregatedProjects()

/**
* Recursively add the modules of the aggregatedProject to the set of aggregatedModules.
*
*
* @param aggregatedProject the project being aggregated
* @param reactorProjectsMap map of (still) available reactor projects
* @param reactorProjectsMap map of (still) available reactor projects
* @throws MavenReportException if any
*/
private Set<MavenProject> modulesForAggregatedProject( MavenProject aggregatedProject,
Expand Down
Loading

0 comments on commit 2b7d2d7

Please sign in to comment.