tags:

views:

822

answers:

2

I'm trying to get the FindBugs ant task to include source info in the generated report.

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

The value of the ${package.srcdir} attribute is correct as far as I can see; it points to the root of the source tree such that ${package.srcdir}/com/mydomain/MyClass.java is the path of the source file.

The generated reports contains a <SrcDir> element which matches the source path given to the ant task, so apparently the <sourcePath> element is handled by the findbugs task. Despite this, the package stats in the XML reports only contains sourceFile="&lt;Unknown&gt;".

Am I missing something obvious?

+1  A: 

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

christian
A: 

Thanks for the answer, christian. I was having the same problem.

Kalyan