Upgrading PMD at Runtime

The Maven PMD plugin comes with a default PMD version: for maven-pmd-plugin 3.10.0, PMD 6.4.0 is used by default.

Given that the newer PMD version is compatible, you can override the PMD version, that the Maven plugin will use and benefit from the latest bugfixes and enhancements:

<project>
  <properties>
    <pmdVersion>...choose your version...</version>
  </properties>
...
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-pmd-plugin</artifactId>
          <version>3.10.0</version>
          <dependencies>
            <dependency>
              <groupId>net.sourceforge.pmd</groupId>
              <artifactId>pmd-core</artifactId>
              <version>${pmdVersion}</version>
            </dependency>
            <dependency>
              <groupId>net.sourceforge.pmd</groupId>
              <artifactId>pmd-java</artifactId>
              <version>${pmdVersion}</version>
            </dependency>
            <dependency>
              <groupId>net.sourceforge.pmd</groupId>
              <artifactId>pmd-javascript</artifactId>
              <version>${pmdVersion}</version>
            </dependency>
            <dependency>
              <groupId>net.sourceforge.pmd</groupId>
              <artifactId>pmd-jsp</artifactId>
              <version>${pmdVersion}</version>
            </dependency>
          </dependencies>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
...
</project>