Java 如何使用Maven FindBugs生成HTML报告?
我知道有人问过类似的问题,但我在pom.xml中的设置有点不同,这个答案对我的案例不起作用 我已经设置了findbugs,这样当我运行[mvn compile findbugs:findbugs]时,就会生成默认的findbugsXML.xml。我想得到一个html文件生成,以便它更可读。下面是我为设置findbugs而添加到pom.xml的内容。考虑到我在编辑pom.xml时包含了该规范,我不确定为什么没有生成html文件。以下内容已添加到build in pom.xml的plugins部分Java 如何使用Maven FindBugs生成HTML报告?,java,xml,maven,Java,Xml,Maven,我知道有人问过类似的问题,但我在pom.xml中的设置有点不同,这个答案对我的案例不起作用 我已经设置了findbugs,这样当我运行[mvn compile findbugs:findbugs]时,就会生成默认的findbugsXML.xml。我想得到一个html文件生成,以便它更可读。下面是我为设置findbugs而添加到pom.xml的内容。考虑到我在编辑pom.xml时包含了该规范,我不确定为什么没有生成html文件。以下内容已添加到build in pom.xml的plugins部分
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>findbugs-cookbook</artifactId>
<packaging>jar</packaging>
<version>3.0.1</version>
<name>FindBugs Maven plugin Cookbook</name>
<description>FindBugs Maven plugin Cookbook</description>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<properties>
<jdk.version>1.7</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>findbugs</finalName>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.1</version>
</plugin>
<!--</plugins>
<plugins> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<effort>Max</effort>
<failOnError>false</failOnError>
<findbugsXmlOutputDirectory>${project.build.directory}/findbugs</findbugsXmlOutputDirectory>
<threshold>Low</threshold>
<xmlOutput>true</xmlOutput>
</configuration>
<executions>
<execution>
<id>analyze-compile</id>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>1.0</version>
<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>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>transform</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>findbugs</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
4.0.0
芬德布格斯食谱
罐子
3.0.1
FindBugs Maven插件食谱
FindBugs Maven插件食谱
Apache许可证2.0
http://www.apache.org/licenses/LICENSE-2.0
1.7
UTF-8
芬德布格斯
真的
src/main/resources
org.codehaus.mojo
findbugs maven插件
3.0.1
org.apache.maven.plugins
maven编译器插件
3.1
${jdk.version}
${jdk.version}
${project.build.sourceEncoding}
org.apache.maven.plugins
maven资源插件
3.0.1
${project.build.sourceEncoding}
org.codehaus.mojo
findbugs maven插件
3.0.1
马克斯
假的
${project.build.directory}/findbugs
低
真的
分析编译
编译
检查
org.codehaus.mojo
xml maven插件
1
${project.build.directory}/findbugs
${project.build.directory}/findbugs
.html
编译
使改变
com.google.code.findbugs
芬德布格斯
3.0.1
我使用的是ApacheMaven3.2.3和Java版本:1.8.0\u20。我还将findbugs-3.0.1.jar和findbugs-maven-plugin-3.0.1.jar包含在我的apache-maven-3.2.3目录中 有4个变量:
- java/JDK版本
- maven版本
- findbugs插件版本
- findbugs版本
绑定findbugs
目标到编译
任务,因此只需运行mvn clean compile
有4个变量:
- java/JDK版本
- maven版本
- findbugs插件版本
- findbugs版本
使用java-1.7,它可以在我的Windows系统上使用指定版本的maven、findbugs、findbugs maven插件。实际上,旧版本的findbugs不适用于Java8
对于java-1.8,如果我使用findbugs和findbugs maven插件的3.0.1版,它就可以工作
由于您已将绑定findbugs
目标到编译
任务,因此只需运行mvn clean compile
,不幸的是,这仍然没有解决我的问题。我已经更新了pom.xml内容,并提供了关于您提到的4个变量的版本的更多信息。对我的问题有什么想法吗?在我的目标文件夹中生成html报告仍然没有成功。。只是xml。您是否有任何错误?另外,您应该运行mvn compile
(我已经更新了答案),因为您已经将findbugs
目标绑定到compile
阶段。不幸的是,这仍然没有解决我的问题。我已经更新了pom.xml内容,并提供了关于您提到的4个变量的版本的更多信息。对我的问题有什么想法吗?在我的目标文件夹中生成html报告仍然没有成功。。只是xml。您是否有任何错误?另外,您应该运行mvncile
(我已经更新了答案),因为您已经将findbugs
目标绑定到compile
阶段。