如何使用Maven 3.x为findbugs生成html报告

Sto*_*oud 13 findbugs maven

有没有人设法配置findbugs Maven 3.x插件来生成xml和html报告?(我想要一个用于Jenkins的xml和一个用于在提交之前进行检查的html)

我见过很多文档设置此功能在网络上,但大部分似乎是Maven的2.x的,这是我知道的配置差异(烦人2.x的配置默默3.X忽略) .我是Maven的新手,所以我不确定我是做错了什么还是我遵循旧的指示.

我的pom包含以下内容:

</build>
    </plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>2.3.3</version>
            <configuration>
                <!-- findbugs:help -Ddetail=true  for outputDirectory:
                     Location where generated html will be created. 
                 -->
                <outputDirectory>${project.build.directory}/findbugs</outputDirectory>

                <xmlOutput>true</xmlOutput>
                <findbugsXmlWithMessages>true</findbugsXmlWithMessages>
                <xmlOutputDirectory>target/findbugs</xmlOutputDirectory>
                <failOnError>false</failOnError>
            </configuration>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

Cor*_*bba 22

Findbugs-Plugin应该在reportPlugins-maven-site-plugin的一部分中.

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-site-plugin</artifactId>
      <configuration>
        <reportPlugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
          </plugin>
        </reportPlugins>
      </configuration>
    </plugin>
  </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

此外,findbugs-report仅在运行之前编译源时生成mvn site.生成网站时,我使用mvn test sitefindbugs生成报告.

  • 顺便说一下,是否有可能将此规则作为构建生命周期的一部分运行?如果找到严重的东西我会想使findbugs失败构建(它还需要生成HTML报告以便我找出问题所在) (2认同)