3

我正在尝试让 FindBugs ant 任务在生成的报告中包含源信息。

<findbugs home="${findbugs.home}" output="xml" outputFile="${basedir}/findbugs/findbugs-${package.basename}.xml" excludeFilter="${basedir}/findbugsExclude.xml" jvmargs="-Xmx1048m">
    <sourcePath path="${package.srcdir}" />
<class location="${package}" />
<auxClasspath>
    <path refid="findbugs.auxinput" />
    </auxClasspath>
</findbugs>

据我所知, ${package.srcdir} 属性的值是正确的;它指向源树的根目录,因此 ${package.srcdir}/com/mydomain/MyClass.java 是源文件的路径。

生成的报告包含一个<SrcDir>与给定 ant 任务的源路径匹配的元素,因此显然该<sourcePath>元素由 findbugs 任务处理。尽管如此,XML 报告中的包统计信息仅包含sourceFile="&lt;Unknown&gt;".

我错过了一些明显的东西吗?

4

2 回答 2

5

I had the same problem.

Probably your code is compiled with "-g:none". If you use ant's <javac> task have to set <javac debug=true>.

Setting the source path correctly (as mentioned in findbugs manual) to the enclosing folder of the top level package (in eclipse projects the src folder) you should be successful.

Nethertheless, afaik there are some cases findbugs can't determine a proper source line number.

cheers, Christian

于 2009-10-01T14:13:08.540 回答
-1

尝试这样的回声(第二行):

<echo message="Finding Bugs From ${package.srcdir}"/>  

我怀疑 package.srcdir 尚未设置为值。尝试使用

<sourcePath path="${basedir}/src/com" />

或包含您的源文件的任何目录。


如果它解决了您的问题,请不要忘记将答案标记为已接受的答案。

于 2013-04-09T10:43:31.210 回答