Java Reference
In-Depth Information
Note
You can define variables in a
build.xml
file by using the
<property>
tag. Once a property is defined, it can be accessed as part of another task using the
${propertyName}
syntax. This allows you to quickly change a build script in re-
sponse to structural changes (for example, switching target/source folders around).
11-4. Finding Bugs Early
Problem
You want to ensure that you are able to find the maximum number of bugs at design
time.
Solution
Use
FindBugs
to scan your software for issues. Use an Ant build file that includes
FindBugs
for reporting purposes.
The following is the new
build.xml
file that adds
FindBugs
reporting:
<project default="test" name="Chapter11Project"
basedir=".">
<property name="src" location="src"/>
<property name="build" location="build/"/>
<property name="reports.tests" location="report/" />
<property name="classpath" location="dep/" />
<!-- Findbugs Static Analyzer Info -->
<property name="findbugs.dir" value="dep/findbugs" />
<property name="findbugs.report" value="findbugs" />
<path id="findbugs.lib" >
<fileset dir="${findbugs.dir}" includes="*.jar"/>
</path>
<taskdef name="findbugs" classpathref="findbugs.lib"
classname="edu.umd.cs.findbugs.anttask.
indBugsTask"/>