eclipse生成findbugs的html报告详细版
eclipse安装findbugs
https://blog.****.net/wyf2017/article/details/80554219 已经非常详细,我就不再赘述。
添加ant的jar
eclipse成功安装findbugs插件后,eclipse的plugins目录->findbugs插件目录->lib目录并没有findbugs.jar和findbugs-ant.jar,所以单独下载findbugs+findbugs-ant.jar
创建ant的build.xml文件
在项目的src目录创建build.xml文件
<project name="项目名称" default="findbugs">
<property name ="findbugs.home" value ="eclipse安装目录\plugins\edu.umd.cs.findbugs.plugin.eclipse_3.0.1.20150306-5afe4d1"/>
<path id="findbugs.lib">
<fileset dir ="${findbugs.home}/lib">
<include name ="findbugs-ant.jar"/>
</fileset>
</path>
<taskdef name="findbugs" classpathref ="findbugs.lib" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"></taskdef>
<target name ="findbugs">
<findbugs home ="${findbugs.home}" jvmargs="-Xmx884m" output ="html" outputFile ="D:/findbugs.html">
<class location ="../target/classes"/>
<auxClasspath path="${findbugs.home}/lib/findbugs-ant.jar"/>
<auxClasspath>
</auxClasspath>
<sourcePath path ="src"/>
</findbugs>
</target>
</project>
<class location ="../target/classes"/>
挑出来说下,不同项目的target目录可能会有不同,ant会默认在项目src下面,我这里的target却是和src同级,所以用…/出去一层;build.xml的其他配置项几乎不用修改了。
生成html报告
eclipse下,build.xml右击Run As->Ant Build
控制台运行完毕,自己去配置的输出文件路径找findbugs.html(我这里配置的D盘)
报错
File not found,那么
<class location ="../target/classes"/>
没有配置正确,可以将target的绝对路径写死在location,也可以像我这样写相对路径。