Exclude pkg from PMD / Findbugs


What's inside this article ⌄
  • Exclude package Maven-PMD
  • Exclude package Findbugs

maven-pmd-plugin

Pmd definition in project pom.xml:

 1<plugin>
 2  <groupId>org.apache.maven.plugins</groupId>
 3  <artifactId>maven-pmd-plugin</artifactId>
 4  <version>${maven.pmd.version}</version>
 5  <configuration>
 6    <rulesets>
 7      <ruleset>C:/dev/test/pmd-exclude.xml</ruleset>
 8    </rulesets>
 9  </configuration>
10  <executions>
11    <execution>
12      <id>pmd check</id>
13      <phase>package</phase>
14      <goals>
15        <goal>check</goal>
16      </goals>
17    </execution>
18  </executions>
19</plugin>

Pmd configuration file pmd-exclude.xml:

1<ruleset>
2  <exclude-pattern>com.example.package/.*</exclude-pattern>
3</ruleset>

findbugs-maven-plugin

Findbugs definition in project pom.xml:

 1<plugin>
 2  <groupId>org.codehaus.mojo</groupId>
 3  <artifactId>findbugs-maven-plugin</artifactId>
 4  <version>${maven.findbugs.version}</version>
 5  <configuration>
 6    <effort>Max</effort>
 7    <threshold>Low</threshold>
 8    <failOnError>true</failOnError>
 9    <excludeFilterFile>C:/dev/test/findbugs-exclude.xml</excludeFilterFile>
10  </configuration>
11  <executions>
12    <execution>
13      <id>analyze-compile</id>
14      <phase>compile</phase>
15      <goals>
16        <goal>check</goal>
17      </goals>
18    </execution>
19  </executions>
20</plugin>

Findbugs configuration file findbugs-exclude.xml:

1<FindBugsFilter>
2  <Match>
3    <Package name="com.example.package"/>
4  </Match>
5</FindBugsFilter>