Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding source paths using FindBugs ant task

Tags:

ant

findbugs

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?

like image 505
JesperE Avatar asked Nov 25 '25 01:11

JesperE


1 Answers

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

like image 170
christian Avatar answered Nov 27 '25 20:11

christian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!