Java 从Maven生成Findbug HTML报告而不使用site:site有什么简单的方法吗?

Java 从Maven生成Findbug HTML报告而不使用site:site有什么简单的方法吗?,java,html,maven,report,findbugs,Java,Html,Maven,Report,Findbugs,我正在尝试将FindBugs集成到maven项目中。是否有人在target中生成一个简单的findbug HTML报告的示例pom.xml?是否可以生成此报告而不必运行site:site 退房。它是一个开放源代码、独立的web服务,您可以向其“提交”代码,并生成关于各种代码度量的漂亮HTML报告。它还保存构建的历史记录。最重要的是,您不必修改构建或POM 它也有一个maven的目标:sonar:sonar。(之前的Hudson)有一个插件,所以如果你在你的CI中使用它,完全没有痛苦 看看吧,你不

我正在尝试将FindBugs集成到maven项目中。是否有人在target中生成一个简单的findbug HTML报告的示例
pom.xml
?是否可以生成此报告而不必运行
site:site

退房。它是一个开放源代码、独立的web服务,您可以向其“提交”代码,并生成关于各种代码度量的漂亮HTML报告。它还保存构建的历史记录。最重要的是,您不必修改构建或POM

它也有一个maven的目标:
sonar:sonar
。(之前的Hudson)有一个插件,所以如果你在你的CI中使用它,完全没有痛苦


看看吧,你不会后悔的

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

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

org.codehaus.mojo
findbugs maven插件
2.4.0
芬德伯格
验证
检查
${project.build.directory}/findbugs
假的
org.codehaus.mojo
xml maven插件
1
验证
使改变
${project.build.directory}/findbugs
${project.build.directory}/findbugs
fancy-hist.xsl
.html
com.google.code.findbugs
芬德布格斯
2.0.0

要获取报告,只需执行
mvn clean install

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


我用maven 3和Finbugs 2.0尝试了它,我正在考虑触发一个ant任务,但maven-findbugs-plugin可能有更好的方法。它看起来很有趣,但我现在在使它工作时遇到了一些麻烦。呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜!!!这比性好。。。你让我的天/周/月/季/年!!!这是梦想的东西!!!mvn清洁安装sonar:sonar+运行sonar服务器,就这样!!!如果可以的话,我会给你1千分的小费@我很乐意帮忙!事实上,通过悬赏给我1k分是可能的:)被否决。问题是关于FindBugs的。“我不能切换到声纳,所以这可能是一个评论,但不是一个答案。”ThiagoNegri其他人显然不同意。如果你费心去检查,你会看到sonar生成了一个FindBugs报告(并且没有site:site),所以这确实回答了这个问题。此外,声纳远远优于仅仅是FindBugs,因此它通过提出一种替代方案来回答这个问题。但至少要感谢你说出你为什么投了反对票。谢谢,这很有效!但是在
true
的情况下,有没有办法生成html输出?那太棒了)@检查这个答案:@LucasCimon是的,我已经检查过了,因为它是我的答案lol)在处理过程中出现以下错误:
无法获取XClass for java/lang/StringBuilder
但是,文件得到了构建,但我在其中找不到任何错误日志。