Java Reference
In-Depth Information
The build.xml also has a new target project called “findbugs.” The findbugs tar-
get compiles the source files with debug information (having debug information helps
on the FindBugs report as it will include the line number when reporting errors), and
then proceeds to analyze the byte-code for errors. In the findbugs task, you specify the
location of the compiled .class files (this is the <class> property), the location of
the dependencies for your project ( <auxClasspath> property), and the location of
the source code ( <sourcePath> property).
Within the findbugs target, there is an <antcall> task. The <antcall> task
simply runs the target specified within the <antcall> task. Just before the <ant-
call> task, you assign the debug <property> to true . This in turns gets passed to
the <javac> task as debug="${debug}" . When the debug <property> is set to
true , the <javac> task will include debug information into the compilation of the
Java source files. Having debug information in the compiled files will help generate a
more readable FindBugs report, as it will include line numbers for where issues are
found. The trick of assigning properties from within an Ant target is used throughout
build.xml files to selectively enable certain behavior when going through specific
build targets. If you were to build the regular build target, the results of the build would
not contain debug information. If instead, you were to build the findbugs target because
the findbugs target replaces the debug <property > to true , the result of the build
would have debug information.
Tip To invoke Ant to run the default “target” (as specified in the build.xml ), you
just type ant . To specify another .xml file (instead of build.xml ), you type ant
-f nameofotherfile.xml . To change the default target to run , you type the
name of the target at the end (for example, ant clean ). To run this example, type
ant -f findbugsbuild.xml findbugs . This will ask Ant to use the find-
bugsbuild.xml file and to run the findbugs target.
11-5. Monitoring Garbage Collection in
your Application
Problem
Search WWH ::




Custom Search