Matthias Bünger created MPMD-386:
------------------------------------

             Summary: Resolution of suppression file failes using the "-f" 
parameter since 3.1.5.0
                 Key: MPMD-386
                 URL: https://issues.apache.org/jira/browse/MPMD-386
             Project: Maven PMD Plugin
          Issue Type: Bug
          Components: PMD
    Affects Versions: 3.21.0, 3.20.0, 3.19.0, 3.18.0, 3.17.0, 3.16.0, 3.15.0
            Reporter: Matthias Bünger
         Attachments: meta-pom.xml

I finally upgraded the maven-pmd-update of our meta POM, because I always 
forgot to upgrade this particular one too. I tried to upgrade from 3.12.0 to 
3.21.0, but realized that our local and CI builds break after upgrading, 
becuase our exclude files are not found anymore, when using the "{{{}-f{}}}" 
parameter.
I could nail it down that the break comes with 3.15.0, but I can not explain 
why. The only ticket I could imagine to has something to do with it is 
MPMD-323, but this is of 3.16.0, so I might be wrong at all.

Background and setup:
We have tons of Maven projects within own repositories, each with one of the 
four structure:

a) Single or multi-module project
b) Root-pom in root directory or in a folder below

The pmd-excludes file lies in same folder as the root-pom. So we have the 
following setups


Single-module
{code}
/
├─ src/
│  ├─ ...
├─ pom.xml
├─ exclude-pmd.properties

 

/
├─ componentDir
   ├─ src/
   │  ├─ ...
   ├─ pom.xml
   ├─ exclude-pmd.properties
{code}

Same for multi module

{code}
/
├─ moduleA
│  ├─src/
│  │  ├─ ...
├─ moduleb
│  ├─src/
│  │  ├─ ...
├─ pom.xml
├─ exclude-pmd.properties

/
├─ componentDir
  ├─ moduleA
  │  ├─src/
  │  │  ├─ ...
  ├─ moduleb
  │  ├─src/
  │  │  ├─ ...
  ├─ pom.xml
  ├─ exclude-pmd.properties
{code}


As we have so many Maven projects we don't create individual Jenkins pipelines 
for each of them due the massive amount of work needed to maintain them. The 
call this in one of the two ways, depending on the the pipeline (verify or 
site), both using the "{{{}-f{}}}" parameter. On local developer machines we 
just start the build in die root pom directory without the "{{{}-f{}}}" 
parameter.

While the resolution of the suppression file of the maven checkstyle plugin 
works like a charm by only using this

{code:xml}
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <configuration>
          
<suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
        </configuration>
      </plugin>
    </plugins>
  </reporting>
{code}

The resolution of the suppression file of the pmd plugin worked somehow 
different, so we used the following universal approach to make it work for all 
our projects

{code:xml}
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
        <configuration>
          
<excludeFromFailureFile>${path.to.suppressfile.wo.slash}/exclude-pmd.properties</excludeFromFailureFile>
        </configuration>
      </plugin>
    </plugins>
  </reporting>
{code}

where "{{{}${path.to.suppressfile.wo.slash}{}}}" is 
"{{{}${project.basedir}/..{}}}" in multi-module projects and 
"{{{}${project.basedir}{}}}" in single-module ones.

This worked until 3.14.0, but failed after I upgraded to 3.15.0 in local and 
Jenkins builds.
I could make the local build work again by changing the configuration to the 
same as the checkstyle plugin

{code:xml}
<excludeFromFailureFile>exclude-pmd.properties</excludeFromFailureFile>
{code}

When I looked at the changes made in MPMD-323, it seems to only affect the 
ruleset file, but it seems to also affects the suppression file, as the maven 
build fails when using the "{{{}-f{}}}" parameter.

As this is my first time I get closer in contact with the PMD plugin sources I 
can't provide any more information right but, except the fact that the 
checkstyle plugin never had these kind of issues starting to use it in 2016 up 
to current version 3.3.0.

Full example meta-pom attached.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to