problem encountered while trying to use ant to run findbugs.......

16 views
Skip to first unread message

fuel

unread,
Nov 27, 2007, 8:52:12 AM11/27/07
to FindBugs
Greetings,
I have got a small problem while trying to run findbugs using
ant. The following shows the build file contents
==============================================
<?xml version="1.0"?>
<project default="findingBugs" name="SimpleProject">
<property name="findBugs.home" value="${user.home}/Desktop/
findbugs-1.0.0"/>
<property name="findBugs.experiment" value="${user.home}/bugs"/>

<taskdef name="FindBugs"
classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
<echo message="${findBugs.experiment}/src/java"/>
<echo message="${findBugs.experiment}/src/java"/>

<target name="findingBugs" depends="compile">
<FindBugs home="${findBugs.home}" output="xml" outputFile="$
{user.home}/result.xml">
<class location="${findBugs.experiment}/bin" />
<sourcePath path="${findBugs.experiment}/src/java/" />
</FindBugs>
</target>

<target name="compile">
<javac srcdir="${findBugs.experiment}/src/java" destdir="$
{findBugs.experiment}/bin" />
</target>

</project>
==============================================================
After running the above build, even though i provide the "sourcePath",
findbugs output does not contain the lines at which the bugs are
found. The same happens when the output is in html format.
How do i resolve this issue ?

The source files for the project I am trying to run findbugs is @ " $
{user.home}/bugs/src/java "
and the generated class files are in the location " ${user.home}/bugs/
bin "

I am also pasting the output xml file. I hope its okay
========================================================
<?xml version="1.0" encoding="UTF-8"?>

<BugCollection version="1.0.0" sequence="0" timestamp="1196170251156"
analysisTimestamp="1196170251187" release="">
<Project filename="&lt;&lt;unnamed project&gt;&gt;">
<Jar>C:\Documents and Settings\fuel\bugs\bin</Jar>
<SrcDir>C:\Documents and Settings\fuel\bugs\src\java</SrcDir>
</Project>
<BugInstance type="DLS_DEAD_LOCAL_STORE" priority="1" abbrev="DLS"
category="STYLE">
<Class classname="com.exp.Hello">
<SourceLine classname="com.exp.Hello" start="-1" end="-1"
startBytecode="-1" endBytecode="-1"/>
</Class>
<Method classname="com.exp.Hello" name="main" signature="([Ljava/
lang/String;)V" isStatic="true">
<SourceLine classname="com.exp.Hello" start="-1" end="-1"
startBytecode="0" endBytecode="27"/>
</Method>
<LocalVariable name="?" register="1" pc="49"
role="LOCAL_VARIABLE_UNKNOWN"/>
<SourceLine classname="com.exp.Hello" start="-1" end="-1"
startBytecode="48" endBytecode="48"/>
</BugInstance>
<BugInstance type="DLS_DEAD_LOCAL_STORE" priority="2" abbrev="DLS"
category="STYLE">
<Class classname="com.exp.Hello">
<SourceLine classname="com.exp.Hello" start="-1" end="-1"
startBytecode="-1" endBytecode="-1"/>
</Class>
<Method classname="com.exp.Hello" name="main" signature="([Ljava/
lang/String;)V" isStatic="true">
<SourceLine classname="com.exp.Hello" start="-1" end="-1"
startBytecode="0" endBytecode="27"/>
</Method>
<LocalVariable name="?" register="1" pc="41"
role="LOCAL_VARIABLE_UNKNOWN"/>
<SourceLine classname="com.exp.Hello" start="-1" end="-1"
startBytecode="40" endBytecode="40"/>
</BugInstance>
<Errors></Errors>
<FindBugsSummary timestamp="Tue, 27 Nov 2007 19:00:51 +0530"
total_classes="1" total_bugs="2" total_size="9" num_packages="1"
clock_seconds="2.23" priority_2="1" priority_1="1">
<PackageStats package="com.exp" total_bugs="2" total_types="1"
total_size="9" priority_2="1" priority_1="1">
<ClassStats class="com.exp.Hello" interface="false" size="9"
bugs="2" priority_2="1" priority_1="1"/>
</PackageStats>
</FindBugsSummary>
<ClassFeatures></ClassFeatures>
<History></History>
</BugCollection>
==========================================================

I tried opening this file using the gui interface. However, it says no
source attached/found. Please let me know how to generate xml/html
output linked to source(line numbers)
thanks,
ajay

fuel

unread,
Nov 28, 2007, 7:13:31 AM11/28/07
to FindBugs
I have solved the problem. The problem was that ant by default
compiles java files with debug=off. If debug information is not
present, then the lines at which the errors occur cannot be
determined. However, after i changed the javac tag with debug="on", i
got all the information including the line number.
thank you!
Reply all
Reply to author
Forward
0 new messages