PMD / checkstyle / findbugs的自定义规则集的建议位置是什么?

时间:2015-12-15 08:46:22

标签: maven checkstyle findbugs pmd

将Maven与PMD,Checkstyle和/或Findbugs的各种插件一起使用时,放置自定义规则集文件的推荐位置是什么?

1 个答案:

答案 0 :(得分:2)

我通常将它们放在一个单独的父pom中,这样我以后可以在其他模块或项目中重复使用它们。 与checkstyle页面(https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html)上的命题类似,但我将其保留在主项目之外。

您将文件放在一个名为build-tools的模块中,其中包含checkstyle和pmd config的src / main / resources / your / package,然后使用以下命令配置给定的插件:

  <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更棘手,我通常会保持原样,有时只使用@SuppressFBWarnings

   <dependency>
        <groupId>com.google.code.findbugs</groupId>
        <artifactId>annotations</artifactId>
        <version>3.0.1</version>
    </dependency>
相关问题