天天看點

eclipse生成findbugs的html報告詳細版

eclipse安裝findbugs

https://blog.csdn.net/wyf2017/article/details/80554219 已經非常詳細,我就不再贅述。

添加ant的jar

eclipse成功安裝findbugs插件後,eclipse的plugins目錄->findbugs插件目錄->lib目錄并沒有findbugs.jar和findbugs-ant.jar,是以單獨下載下傳findbugs+findbugs-ant.jar
eclipse生成findbugs的html報告詳細版

建立ant的build.xml檔案

在項目的src目錄建立build.xml檔案
eclipse生成findbugs的html報告詳細版
<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
eclipse生成findbugs的html報告詳細版
eclipse生成findbugs的html報告詳細版

控制台運作完畢,自己去配置的輸出檔案路徑找findbugs.html(我這裡配置的D盤)

報錯

File not found,那麼

<class location ="../target/classes"/>

沒有配置正确,可以将target的絕對路徑寫死在location,也可以像我這樣寫相對路徑。
eclipse生成findbugs的html報告詳細版

繼續閱讀