【问题标题】:How to generate a html report for findbugs with Maven 3.x如何使用 Maven 3.x 为 findbugs 生成 html 报告
【发布时间】:2012-01-23 18:04:29
【问题描述】:

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

我在网络上看到了很多关于设置的文档,但其中大部分似乎是针对 Maven 2.x 的,我知道它的配置不同(令人讨厌的是 2.x)。 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>

【问题讨论】:

    标签: maven findbugs


    【解决方案1】:

    Findbugs-Plugin 应该在 maven-site-plugin 的 reportPlugins-Part 中。

    <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>
    

    此外,findbugs-report 仅在运行mvn site 之前编译源代码时生成。生成网站时,我使用mvn test site,所以 findbugs 会生成报告。

    【讨论】:

    • 完美。只有一件事:我必须在内部插件中添加一个 2.3.3 以消除 Maven 警告消息。谢谢
    • 顺便说一句,是否可以将此规则作为构建生命周期的一部分运行?如果发现严重问题,我希望 findbugs 无法构建(它还需要生成 HTML 报告,以便我找出问题所在)
    • 根据plugin-website,有一个findbugs:check 目标,默认绑定到verify 阶段,让构建因任何错误而失败。但是这个目标只会有 xml 输出。
    • 感谢您的信息。它解释了为什么我在尝试让它工作时遇到了这么多麻烦!这是一种奇怪而痛苦的工作方式——如果 findbugs 会破坏构建(我的要求),那么我想要一份人类可读的报告来告诉我原因!哦,好吧...
    【解决方案2】:

    查看我的answer 是否有类似问题,我建议在执行mvn clean install 命令期间使用 Findbugs 附带的 XSLT 转换来生成 HTML 报告。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-27
      • 2011-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多