You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/02/12 00:09:39 UTC

[maven-pmd-plugin] branch doxia-2.0.0 updated (cb36e85 -> d149363)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch doxia-2.0.0
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git


 discard cb36e85  Prepare for Doxia 2.0.0
     add f3e188a  [MPMD-361] Explicitly start and end tables with Doxia Sinks in report renderers
     add 55c4d40  [maven-release-plugin] prepare release maven-pmd-plugin-3.20.0
     add e6f88da  [maven-release-plugin] prepare for next development iteration
     add 806c49d  (doc) Update releasenotes.md [skip ci]
     add 5826c88  [MPMD-364] - Upgrade to PMD 6.54.0 (#112)
     new d149363  Prepare for Doxia 2.0.0

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (cb36e85)
            \
             N -- N -- N   refs/heads/doxia-2.0.0 (d149363)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pom.xml                                             | 16 ++++++++--------
 .../apache/maven/plugins/pmd/AbstractPmdReport.java | 14 +++++---------
 .../maven/plugins/pmd/CpdReportGenerator.java       |  2 +-
 .../maven/plugins/pmd/PmdReportGenerator.java       |  6 +++---
 .../apt/examples/upgrading-PMD-at-runtime.apt.vm    |  2 ++
 src/site/markdown/releasenotes.md                   | 21 ++++++++++++++++++---
 .../plugins/pmd/AbstractPmdReportTestCase.java      |  6 ++++++
 .../stubs/CustomConfigurationMavenProjectStub.java  | 18 ++++++++++++++----
 .../stubs/DefaultConfigurationMavenProjectStub.java | 18 ++++++++++++++----
 .../pmd/stubs/InvalidFormatMavenProjectStub.java    | 18 ++++++++++++++----
 .../maven/plugins/pmd/stubs/PmdProjectStub.java     | 18 ++++++++++++++++++
 11 files changed, 103 insertions(+), 36 deletions(-)


[maven-pmd-plugin] 01/01: Prepare for Doxia 2.0.0

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch doxia-2.0.0
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git

commit d1493637440642840f1030a4393b143fc5808296
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Dec 3 00:05:15 2022 +0100

    Prepare for Doxia 2.0.0
---
 pom.xml                                            | 50 ++++++----------------
 .../maven/plugins/pmd/AbstractPmdReport.java       | 14 +++---
 .../maven/plugins/pmd/CpdReportGenerator.java      |  2 +-
 .../maven/plugins/pmd/PmdReportGenerator.java      |  6 +--
 .../plugins/pmd/AbstractPmdReportTestCase.java     |  6 +++
 .../apache/maven/plugins/pmd/CpdReportTest.java    |  2 -
 .../apache/maven/plugins/pmd/PmdReportTest.java    |  8 ++--
 .../stubs/CustomConfigurationMavenProjectStub.java | 18 ++++++--
 .../DefaultConfigurationMavenProjectStub.java      | 18 ++++++--
 .../pmd/stubs/InvalidFormatMavenProjectStub.java   | 18 ++++++--
 .../maven/plugins/pmd/stubs/PmdProjectStub.java    | 18 ++++++++
 11 files changed, 90 insertions(+), 70 deletions(-)

diff --git a/pom.xml b/pom.xml
index c17a29f..0479a87 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@ under the License.
   </parent>
 
   <artifactId>maven-pmd-plugin</artifactId>
-  <version>3.20.1-SNAPSHOT</version>
+  <version>4.0.0-M1-SNAPSHOT</version>
   <packaging>maven-plugin</packaging>
 
   <name>Apache Maven PMD Plugin</name>
@@ -86,15 +86,14 @@ under the License.
 
   <properties>
     <mavenVersion>3.2.5</mavenVersion>
-    <doxiaVersion>1.11.1</doxiaVersion>
-    <doxiaSitetoolsVersion>1.11.1</doxiaSitetoolsVersion>
+    <doxiaVersion>2.0.0-M5</doxiaVersion>
     <javaVersion>8</javaVersion><!-- Because PMD 6.35.0+ requires Java 8 -->
     <pmdVersion>6.54.0</pmdVersion>
     <slf4jVersion>1.7.36</slf4jVersion>
     <aetherVersion>1.0.0.v20140518</aetherVersion>
-    <sitePluginVersion>3.12.1</sitePluginVersion>
-    <projectInfoReportsPluginVersion>3.4.1</projectInfoReportsPluginVersion>
-    <jxrPluginVersion>3.3.0</jxrPluginVersion>
+    <sitePluginVersion>4.0.0-M5</sitePluginVersion>
+    <projectInfoReportsPluginVersion>4.0.0-M1-SNAPSHOT</projectInfoReportsPluginVersion>
+    <jxrPluginVersion>4.0.0-M1-SNAPSHOT</jxrPluginVersion>
     <project.build.outputTimestamp>2023-01-06T22:00:33Z</project.build.outputTimestamp>
   </properties>
 
@@ -118,6 +117,12 @@ under the License.
       <version>${mavenVersion}</version>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-compat</artifactId>
+      <version>${mavenVersion}</version>
+      <scope>provided</scope>
+    </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
@@ -191,43 +196,12 @@ under the License.
       <artifactId>doxia-sink-api</artifactId>
       <version>${doxiaVersion}</version>
     </dependency>
-    <dependency>
-      <groupId>org.apache.maven.doxia</groupId>
-      <artifactId>doxia-decoration-model</artifactId>
-      <version>${doxiaSitetoolsVersion}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.doxia</groupId>
-      <artifactId>doxia-site-renderer</artifactId>
-      <version>${doxiaSitetoolsVersion}</version>
-      <!--
-        Note: doxia-site-renderer needs to be defined AFTER pmd:
-        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.1</version>
-    </dependency>
     <dependency>
       <groupId>org.apache.maven.reporting</groupId>
       <artifactId>maven-reporting-impl</artifactId>
-      <version>3.2.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.shared</groupId>
-      <artifactId>maven-shared-utils</artifactId>
-      <version>3.3.4</version>
+      <version>4.0.0-M4</version>
     </dependency>
 
     <!-- plexus -->
diff --git a/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java b/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
index c262397..8f459c7 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
@@ -245,12 +245,6 @@ public abstract class AbstractPmdReport
     // Read-only parameters
     // ----------------------------------------------------------------------
 
-    /**
-     * The projects in the reactor for aggregation report.
-     */
-    @Parameter( property = "reactorProjects", readonly = true )
-    protected List<MavenProject> reactorProjects;
-
     /**
      * The current build session instance. This is used for
      * toolchain manager API calls and for dependency resolver API calls.
@@ -264,15 +258,17 @@ public abstract class AbstractPmdReport
     /** The files that are being analyzed. */
     protected Map<File, PmdFileInfo> filesToProcess;
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     protected MavenProject getProject()
     {
         return project;
     }
 
+    protected List<MavenProject> getReactorProjects()
+    {
+        return reactorProjects;
+    }
+
     protected String constructXRefLocation( boolean test )
     {
         String location = null;
diff --git a/src/main/java/org/apache/maven/plugins/pmd/CpdReportGenerator.java b/src/main/java/org/apache/maven/plugins/pmd/CpdReportGenerator.java
index 1823055..7552c3c 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/CpdReportGenerator.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/CpdReportGenerator.java
@@ -165,7 +165,7 @@ public class CpdReportGenerator
             String code = duplication.getCodefragment();
 
             sink.table();
-            sink.tableRows( null, false );
+            sink.tableRows();
             sink.tableRow();
             sink.tableHeaderCell();
             sink.text( bundle.getString( "report.cpd.column.file" ) );
diff --git a/src/main/java/org/apache/maven/plugins/pmd/PmdReportGenerator.java b/src/main/java/org/apache/maven/plugins/pmd/PmdReportGenerator.java
index 623b7c9..529c720 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/PmdReportGenerator.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/PmdReportGenerator.java
@@ -166,7 +166,7 @@ public class PmdReportGenerator
         sink.sectionTitle_( level );
 
         sink.table();
-        sink.tableRows( null, false );
+        sink.tableRows();
         sink.tableRow();
         sink.tableHeaderCell();
         sink.text( bundle.getString( "report.pmd.column.rule" ) );
@@ -408,7 +408,7 @@ public class PmdReportGenerator
         } );
 
         sink.table();
-        sink.tableRows( null, false );
+        sink.tableRows();
         sink.tableRow();
         sink.tableHeaderCell();
         sink.text( bundle.getString( "report.pmd.suppressedViolations.column.filename" ) );
@@ -475,7 +475,7 @@ public class PmdReportGenerator
         sink.sectionTitle1_();
 
         sink.table();
-        sink.tableRows( null, false );
+        sink.tableRows();
         sink.tableRow();
         sink.tableHeaderCell();
         sink.text( bundle.getString( "report.pmd.processingErrors.column.filename" ) );
diff --git a/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java b/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java
index f0d5524..bfd9e9d 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java
@@ -22,6 +22,8 @@ package org.apache.maven.plugins.pmd;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
+import java.util.Collections;
+import java.util.List;
 import java.util.Locale;
 
 import org.apache.maven.plugin.LegacySupport;
@@ -121,8 +123,12 @@ public abstract class AbstractPmdReportTestCase
             (DefaultRepositorySystemSession) legacySupport.getRepositorySession();
         repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repoSession, new LocalRepository( artifactStubFactory.getWorkingDir() ) ) );
 
+        List<MavenProject> reactorProjects = mojo.getReactorProjects() != null ? mojo.getReactorProjects() : Collections.emptyList();
+
         setVariableValueToObject( mojo, "session", legacySupport.getSession() );
+        setVariableValueToObject( mojo, "reactorProjects", reactorProjects );
         setVariableValueToObject( mojo, "remoteRepositories", mojo.getProject().getRemoteArtifactRepositories() );
+        setVariableValueToObject( mojo, "siteDirectory", new File( mojo.getProject().getBasedir(), "src/site" ) );
         return mojo;
     }
 
diff --git a/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java
index efb3d58..1ba8e7c 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java
@@ -23,7 +23,6 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
-import java.util.Locale;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -47,7 +46,6 @@ public class CpdReportTest
         throws Exception
     {
         super.setUp();
-        Locale.setDefault( Locale.ENGLISH );
         FileUtils.deleteDirectory( new File( getBasedir(), "target/test/unit" ) );
     }
 
diff --git a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
index d53ba48..e94b930 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
@@ -26,7 +26,6 @@ import java.io.IOException;
 import java.net.ServerSocket;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
-import java.util.Locale;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -55,7 +54,6 @@ public class PmdReportTest
         throws Exception
     {
         super.setUp();
-        Locale.setDefault( Locale.ENGLISH );
         FileUtils.deleteDirectory( new File( getBasedir(), "target/test/unit" ) );
     }
 
@@ -93,9 +91,9 @@ public class PmdReportTest
         assertTrue( str.contains( "pmd_rules_java_bestpractices.html#unusedprivatefield\">UnusedPrivateField</a>" ) );
 
         // there should be the section Violations By Priority
-        assertTrue( str.contains( "Violations By Priority</h2>" ) );
-        assertTrue( str.contains( "Priority 3</h3>" ) );
-        assertTrue( str.contains( "Priority 4</h3>" ) );
+        assertTrue( str.contains( "Violations By Priority</h1>" ) );
+        assertTrue( str.contains( "Priority 3</h2>" ) );
+        assertTrue( str.contains( "Priority 4</h2>" ) );
         // the file App.java is mentioned 3 times: in prio 3, in prio 4 and in the files section
         assertEquals( 3, StringUtils.countMatches( str, "def/configuration/App.java" ) );
 
diff --git a/src/test/java/org/apache/maven/plugins/pmd/stubs/CustomConfigurationMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pmd/stubs/CustomConfigurationMavenProjectStub.java
index 4fe1d67..59448eb 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/stubs/CustomConfigurationMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/stubs/CustomConfigurationMavenProjectStub.java
@@ -51,7 +51,7 @@ public class CustomConfigurationMavenProjectStub
         {
             model =
                 pomReader.read( new FileReader( new File( getBasedir()
-                    + "/src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml" ) ) );
+                    + "/" + getPOM() ) ) );
             setModel( model );
         }
         catch ( Exception e )
@@ -72,15 +72,15 @@ public class CustomConfigurationMavenProjectStub
 
         Build build = new Build();
         build.setFinalName( model.getBuild().getFinalName() );
-        build.setDirectory( getBasedir() + "/target/test/unit/custom-configuration/target" );
-        build.setSourceDirectory( getBasedir() + "/src/test/resources/unit/custom-configuration" );
+        build.setDirectory( getBasedir() + "/target" );
+        build.setSourceDirectory( getBasedir().getAbsolutePath() );
         setBuild( build );
 
         setReportPlugins( model.getReporting().getPlugins() );
 
         String basedir = getBasedir().getAbsolutePath();
         List<String> compileSourceRoots = new ArrayList<>();
-        compileSourceRoots.add( basedir + "/src/test/resources/unit/custom-configuration/custom/configuration" );
+        compileSourceRoots.add( basedir + "/custom/configuration" );
         setCompileSourceRoots( compileSourceRoots );
 
         Artifact artifact = new PmdPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() );
@@ -116,4 +116,14 @@ public class CustomConfigurationMavenProjectStub
         return reportPlugins;
     }
 
+    @Override
+    public File getBasedir() {
+        return new File( super.getBasedir() + "/custom-configuration" );
+    }
+
+    @Override
+    protected String getPOM() {
+        return "custom-configuration-plugin-config.xml";
+    }
+
 }
diff --git a/src/test/java/org/apache/maven/plugins/pmd/stubs/DefaultConfigurationMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pmd/stubs/DefaultConfigurationMavenProjectStub.java
index daac795..472c88a 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/stubs/DefaultConfigurationMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/stubs/DefaultConfigurationMavenProjectStub.java
@@ -48,7 +48,7 @@ public class DefaultConfigurationMavenProjectStub
         Model model = null;
 
         try ( FileReader reader = new FileReader( new File( getBasedir()
-            + "/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" ) ) )
+            + "/" + getPOM() ) ) )
         {
             model = pomReader.read( reader );
             setModel( model );
@@ -72,8 +72,8 @@ public class DefaultConfigurationMavenProjectStub
         Build build = new Build();
         build.setFinalName( model.getBuild()
                                  .getFinalName() );
-        build.setDirectory( getBasedir() + "/target/test/unit/default-configuration/target" );
-        build.setSourceDirectory( getBasedir() + "/src/test/resources/unit/default-configuration" );
+        build.setDirectory( getBasedir() + "/target" );
+        build.setSourceDirectory( getBasedir().getAbsolutePath() );
         setBuild( build );
 
         setReportPlugins( model.getReporting()
@@ -81,7 +81,7 @@ public class DefaultConfigurationMavenProjectStub
 
         String basedir = getBasedir().getAbsolutePath();
         List<String> compileSourceRoots = new ArrayList<>();
-        compileSourceRoots.add( basedir + "/src/test/resources/unit/default-configuration/def/configuration" );
+        compileSourceRoots.add( basedir + "/def/configuration" );
         setCompileSourceRoots( compileSourceRoots );
 
         File file = new File( getBasedir().getAbsolutePath() + "/pom.xml" );
@@ -118,4 +118,14 @@ public class DefaultConfigurationMavenProjectStub
     {
         return build;
     }
+
+    @Override
+    public File getBasedir() {
+        return new File( super.getBasedir() + "/default-configuration" );
+    }
+
+    @Override
+    protected String getPOM() {
+        return "default-configuration-plugin-config.xml";
+    }
 }
diff --git a/src/test/java/org/apache/maven/plugins/pmd/stubs/InvalidFormatMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pmd/stubs/InvalidFormatMavenProjectStub.java
index f700313..57612e5 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/stubs/InvalidFormatMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/stubs/InvalidFormatMavenProjectStub.java
@@ -48,7 +48,7 @@ public class InvalidFormatMavenProjectStub
         {
             model =
                 pomReader.read( new FileReader( new File( getBasedir()
-                    + "/src/test/resources/unit/invalid-format/invalid-format-plugin-config.xml" ) ) );
+                    + "/" + getPOM() ) ) );
             setModel( model );
         }
         catch ( Exception e )
@@ -69,13 +69,13 @@ public class InvalidFormatMavenProjectStub
 
         Build build = new Build();
         build.setFinalName( model.getBuild().getFinalName() );
-        build.setDirectory( getBasedir() + "/target/test/unit/invalid-format/target" );
-        build.setSourceDirectory( getBasedir() + "/src/test/resources/unit/invalid-format" );
+        build.setDirectory( getBasedir() + "/target" );
+        build.setSourceDirectory( getBasedir().getAbsolutePath() );
         setBuild( build );
 
         String basedir = getBasedir().getAbsolutePath();
         List<String> compileSourceRoots = new ArrayList<>();
-        compileSourceRoots.add( basedir + "/src/test/resources/unit/invalid-format/invalid/format" );
+        compileSourceRoots.add( basedir + "/invalid/format" );
         setCompileSourceRoots( compileSourceRoots );
 
         Artifact artifact = new PmdPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() );
@@ -100,4 +100,14 @@ public class InvalidFormatMavenProjectStub
         return build;
     }
 
+    @Override
+    public File getBasedir() {
+        return new File( super.getBasedir() + "/invalid-format" );
+    }
+
+    @Override
+    protected String getPOM() {
+        return "invalid-format-plugin-config.xml";
+    }
+
 }
diff --git a/src/test/java/org/apache/maven/plugins/pmd/stubs/PmdProjectStub.java b/src/test/java/org/apache/maven/plugins/pmd/stubs/PmdProjectStub.java
index 0b8f6f9..638cf44 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/stubs/PmdProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/stubs/PmdProjectStub.java
@@ -19,6 +19,7 @@ package org.apache.maven.plugins.pmd.stubs;
  * under the License.
  */
 
+import java.io.File;
 import java.util.Collections;
 import java.util.List;
 
@@ -31,6 +32,23 @@ import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 public abstract class PmdProjectStub
     extends MavenProjectStub
 {
+    /**
+     * @return the POM file name
+     */
+    protected abstract String getPOM();
+
+    @Override
+    public File getBasedir()
+    {
+        return new File( super.getBasedir() + "/src/test/resources/unit/" );
+    }
+
+    @Override
+    public File getFile()
+    {
+        return new File( getBasedir(), getPOM() );
+    }
+
     @Override
     public List<ArtifactRepository> getRemoteArtifactRepositories()
     {