How to make maven-pmd-plugin support the latest PMD release?

0 votes
asked Jan 9, 2010 by joe

http://maven.apache.org/plugins/maven-pmd-plugin/ is currently in version 2.4 which supports PMD version 4.2.2

Is it possible to use PMD version 4.2.5 with this plugin, if so how do we do this?

2 Answers

0 votes
answered Jan 9, 2010 by pascal-thivent

There is a Jira Issue for this, see MPMD-97 (I suggest to vote for it).

For now, you can try to upgrade locally the pmd version used in the plugin with:

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
        <version>2.4</version>

        <dependencies>

          <dependency>
              <groupId>pmd</groupId>
              <artifactId>pmd-jdk14</artifactId>
              <version>4.2.5</version>
          </dependency>

        </dependencies>
      </plugin>
    </plugins>
  </build>

I didn't test this, I don't know if it'll work seamlessly.

0 votes
answered Sep 15, 2017 by ed-randall

This is an old question and things have moved on, but I still faced a challenge upgrading maven-pmd-plugin:3.8 from pmd 5.6.1 to 5.8.1. The documentation for doing this is still missing from the maven-pmd-plugin page.

  1. Add pmd-core, pmd-java and any other mavenized PMD artifacts as plugin dependencies.
  2. If your rules are contained within in a separate .jar module, add that module to the dependencies also.
  3. Ensure that the check goal is run after the compile phase - validate is too soon. (I picked process-test-classes to invoke it just before any tests are run rather than the more usual verify which is also OK but will run it later).

pom.xml configuration:

<properties>
    <rev.javac>1.8</rev.javac>
    <rev.pmd-plugin>3.8</rev.pmd-plugin>
    <rev.pmd>5.8.1</rev.pmd>
</properties>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pmd-plugin</artifactId>
    <version>${rev.pmd-plugin}</version>
    <dependencies>
        <dependency>
            <groupId>my.project.group</groupId>
            <artifactId>project-standards</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.pmd</groupId>
            <artifactId>pmd-core</artifactId>
            <version>${rev.pmd}</version>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.pmd</groupId>
            <artifactId>pmd-java</artifactId>
            <version>${rev.pmd}</version>
        </dependency>
    </dependencies>
    <executions>
        <execution>
            <id>pmd-validation</id>
            <phase>process-test-classes</phase>
            <goals>
                <goal>check</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <rulesets>
            <ruleset>/pmd/project-pmd-rules.xml</ruleset>
        </rulesets>
        <targetDirectory>${project.build.directory}</targetDirectory>
        <targetJdk>${rev.javac}</targetJdk>
        <failOnViolation>true</failOnViolation>
        <failurePriority>5</failurePriority>
        <verbose>false</verbose>
        <linkXRef>false</linkXRef>
    </configuration>
</plugin>
Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter

...