Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the recommended location for custom ruleset for PMD/checkstyle/findbugs? [closed]

When using Maven with the various plugins for PMD, Checkstyle and/or Findbugs, what would be the recommended location for placing your custom ruleset file?

like image 253
Wim Deblauwe Avatar asked Oct 31 '22 13:10

Wim Deblauwe


1 Answers

I usually place them in a separate parent pom, this way I can reuse them later on in other modules or projects. Similar to the proposition on checkstyle page (https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html) but I keep it out of the main project.

You place the files a module named build-tools in which you have src/main/resources/your/package with checkstyle and pmd config and then configure given plugin with:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>2.17</version>
    <dependencies>
      <dependency>
        <groupId>com.example.whizbang</groupId>
        <artifactId>build-tools</artifactId>
        <version>1.0</version>
      </dependency>
    </dependencies>
  </plugin>

FindBugs is more tricky, I usually leave it as it is, and sometimes only use @SuppressFBWarnings from:

   <dependency>
        <groupId>com.google.code.findbugs</groupId>
        <artifactId>annotations</artifactId>
        <version>3.0.1</version>
    </dependency>
like image 155
Krzysztof Krasoń Avatar answered Dec 15 '22 03:12

Krzysztof Krasoń