如何将FindBugs配置为仅在多模块maven项目中的一个项目上运行

时间:2013-06-17 14:29:29

标签: maven findbugs

我使用findbugs-maven-plugin来检查maven的bug。我的maven项目是一个多模块项目,大致如下:

java-module
    pom.xml
    src/ ...
pom.xml
scala-module
    pom.xml
    src/ ...

我使用Jenkins构建和测试项目,Jenkins在最顶层的目录中运行目标findbugs:findbugs。由于FindBugs报告了Scala编译器生成的代码的许多虚假警告,我想告诉FindBugs不要分析scala-module中的代码。但是,当我在最顶层的目录中运行findbugs:findbugs时,它始终会分析java-modulescala-module中的所有类。我如何告诉maven忽略scala-module整体?我知道FindBugs排除了过滤器,但我想为FindBugs提供一个配置选项,告诉它只是不分析某个子模块中的代码。

FindBugs在子目录pom.xml的{​​{1}}中配置如下:

java-module

尽管仅针对<reporting> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId> <version>${version.plugin.codehaus.findbugs}</version> <configuration> <findbugsXmlOutput>true</findbugsXmlOutput> <findbugsXmlWithMessages>true</findbugsXmlWithMessages> <xmlOutput>true</xmlOutput> </configuration> </plugin> </plugins> </reporting> 进行了配置,但FindBugs将始终分析java-module

2 个答案:

答案 0 :(得分:2)

添加scala-module pom.xml的配置,该模块明确指示findbugs跳过该模块,即

<reporting>
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>findbugs-maven-plugin</artifactId>
      <configuration>
        <skip>true</skip>
      </configuration>
    </plugin>
  </plugins>
</reporting>

请注意,Maven经常要求您为这样的情况重复样板XML。

答案 1 :(得分:1)

Noahlz的回答对我不起作用,但是将以下片段添加到子模块的POM.xml中就可以了。

<properties>
    <findbugs.skip>true</findbugs.skip>
</properties>
相关问题