从没有site:site的Maven生成Findbug HTML报告的简单方法?

Jér*_*nge 11 html java findbugs report maven

我正在尝试将FindBugs集成到maven项目中.有没有人有一个样本pom.xml在目标中生成一个简单的findbug HTML报告?是否可以生成此报告而无需运行site:site

roz*_*zky 27

Findbugs jar包含5个XSLT转换,可用于将难以读取的XML转换为易于阅读的HTML,因此我们可以使用xml-maven-plugin插件来执行转换,这里是配置:

<plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>2.4.0</version>
        <executions>
            <execution>
                <id>findbug</id>
                <phase>verify</phase>
                <goals>
                    <goal>check</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <findbugsXmlOutputDirectory>
                ${project.build.directory}/findbugs
            </findbugsXmlOutputDirectory>
            <failOnError>false</failOnError>
        </configuration>
    </plugin>

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>xml-maven-plugin</artifactId>
        <version>1.0</version>
        <executions>
            <execution>
                <phase>verify</phase>
                <goals>
                    <goal>transform</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <transformationSets>
                <transformationSet>
                    <dir>${project.build.directory}/findbugs</dir>
                    <outputDir>${project.build.directory}/findbugs</outputDir>
                    <stylesheet>fancy-hist.xsl</stylesheet>
                    <!--<stylesheet>default.xsl</stylesheet>-->
                    <!--<stylesheet>plain.xsl</stylesheet>-->
                    <!--<stylesheet>fancy.xsl</stylesheet>-->
                    <!--<stylesheet>summary.xsl</stylesheet>-->
                    <fileMappers>
                        <fileMapper
                                implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                            <targetExtension>.html</targetExtension>
                        </fileMapper>
                    </fileMappers>
                </transformationSet>
            </transformationSets>
        </configuration>
        <dependencies>
            <dependency>
                <groupId>com.google.code.findbugs</groupId>
                <artifactId>findbugs</artifactId>
                <version>2.0.0</version>
            </dependency>
        </dependencies>
    </plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)

要使报告刚刚执行mvn clean install.

上面的代码片段包含所有5种可能的转换,因此请尝试所有转换,希望您能找到自己喜欢的转换.

我用maven 3和Finbugs 2.0试了一下


Boh*_*ian 4

看看声纳。它是一个开源、独立的 Web 服务,您可以将代码“提交”到它,它会生成有关各种代码指标的精美 HTML 报告。它还保留构建历史。最重要的是,您不必修改您的构建或 pom!

它也有一个 Maven 目标:sonar:sonar. Jenkins(以前的 Hudson)有一个插件,所以如果你将它用于 CI,那是完全无痛的。

看看吧 - 你不会后悔的!

  • 呜啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊 这比性更好......你让我的一天/周/月/季度/年!!!这是梦想的东西!mvn clean install sonar:sonar + 运行声纳服务器就这样了!如果可以的话,我会给你 1k 点的小费! (4认同)