logo Apache Maven PMD Plugin

A Maven plugin for the PMD toolkit, that produces a report on both code rule violations and detected copy and paste fragments, as well as being able to fail the build based on these metrics.

homepage: maven.apache.org/plugins
fresh index:
last release: 4 months ago, first release: 2 decades ago
packaging: maven-plugin
get this artifact from: central
see this artifact on: search.maven.org


Display vulnerabilities (snyk): Vulnerability check

This chart shows how much is this artifact used as a dependency in other Maven artifacts in Central repository and GitHub:


select version:

Add this snippet into pom.xml inside tag <project><build><plugins>:




Switch to artifact.
goals:
pmd:aggregate-cpd

Creates a report for PMD's Copy/Paste Detector (CPD) tool in an aggregator project. It can also generate a cpd results file in any of these formats: xml, csv or txt. See Finding duplicated code for more details.

pmd:aggregate-cpd-check (phase: verify)

Fail the build in an aggregator project if there were any CPD violations in the source code.

pmd:aggregate-pmd

Creates a PMD site report in an aggregator project based on the rulesets and configuration set in the plugin. It can also generate a pmd output file aside from the site report in any of the following formats: xml, csv or txt.

pmd:aggregate-pmd-check (phase: verify)

Fails the build in an aggregator project if there were any PMD violations in the source code.

pmd:aggregate-pmd-no-fork

Creates a PMD site report in an aggregator project without forking the test-compile phase again.

pmd:check (phase: verify)

Fails the build if there were any PMD violations in the source code.

pmd:cpd

Creates a report for PMD's Copy/Paste Detector (CPD) tool. It can also generate a cpd results file in any of these formats: xml, csv or txt. See Finding duplicated code for more details.

pmd:cpd-check (phase: verify)

Fails the build if there were any CPD violations in the source code.

pmd:help

Display help information on maven-pmd-plugin. Call mvn pmd:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.

pmd:pmd

Creates a PMD site report based on the rulesets and configuration set in the plugin. It can also generate a pmd output file aside from the site report in any of the following formats: xml, csv or txt.

Often used code snippets:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-pmd-plugin</artifactId>
  <version>3.5</version>
  <configuration>
    <linkXref>true</linkXref>
    <sourceEncoding>UTF8</sourceEncoding>
    <minimumTokens>30</minimumTokens>
    <targetJdk>1.7</targetJdk>
  </configuration>
  <executions>
    <execution>
      <phase>verify</phase>
      <goals>
        <goal>pmd</goal>
        <goal>cpd</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-pmd-plugin</artifactId>
  <version>3.5</version>
  <configuration>
    <sourceEncoding>UTF8</sourceEncoding>
    <minimumTokens>30</minimumTokens>
    <targetJdk>1.7</targetJdk>
  </configuration>
  <executions>
    <execution>
      <phase>verify</phase>
      <goals>
        <goal>pmd</goal>
        <goal>cpd</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-pmd-plugin</artifactId>
  <version>3.5</version>
  <configuration>
    <linkXref>true</linkXref>
    <sourceEncoding>UTF8</sourceEncoding>
    <minimumTokens>30</minimumTokens>
    <targetJdk>1.8</targetJdk>
  </configuration>
  <executions>
    <execution>
      <phase>verify</phase>
      <goals>
        <goal>pmd</goal>
        <goal>cpd</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-pmd-plugin</artifactId>
  <version>3.11.0</version>
  <configuration>
    <printFailingErrors>true</printFailingErrors>
    <linkXRef>false</linkXRef>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>check</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-pmd-plugin</artifactId>
  <version>3.12.0</version>
  <configuration>
    <printFailingErrors>true</printFailingErrors>
    <linkXRef>false</linkXRef>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>check</goal>
      </goals>
    </execution>
  </executions>
</plugin>

© Jiri Pinkas 2015 - 2022. All rights reserved! Admin login To submit bugs / feature requests please use this github page
related: JavaVids | Top Java Blogs | Java školení
Apache and Apache Maven are trademarks of the Apache Software Foundation. The Central Repository is a service mark of Sonatype, Inc.