2

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

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

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

FindBugspom.xml在子目录中配置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>

尽管只针对 进行了配置java-module,FindBugs 也会始终进行分析scala-module

4

2 回答 2

2

添加一个配置 scala-modulepom.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。

于 2013-06-18T13:44:54.750 回答
1

Noahlz's answer did not work for me, but adding the following snippet to the sub-module's POM.xml did the trick.

<properties>
    <findbugs.skip>true</findbugs.skip>
</properties>
于 2013-07-22T07:23:29.090 回答