Reputation: 83
I am building my application using ANT and I am checking my code for any Findbugs violations.
Now, my objective is to stop the build whenever my code contains particular findbug violation.
Is this possible using ANT & Findbugs?
N.B. Preferably not to write to any custom class.
Upvotes: 7
Views: 1426
Reputation: 66723
Use the warningsProperty attribute on your findbugs task to set a property for any warnings:
<findbugs ... warningsProperty="findbugsFailure"/>
and fail task
if warnings are produced:
<fail if="findbugsFailure">
For example:
<property name="findbugs.home" value="/export/home/daveho/work/findbugs" />
<target name="findbugs" depends="jar">
<findbugs home="${findbugs.home}"
output="xml"
outputFile="bcel-fb.xml"
warningsProperty="findbugsFailure">
<auxClasspath path="${basedir}/lib/Regex.jar" />
<sourcePath path="${basedir}/src/java" />
<class location="${basedir}/bin/bcel.jar" />
</findbugs>
<fail if="findbugsFailure">
</target>
Upvotes: 4
Reputation: 77961
An alternative idea (and worth the effort) would be to integrate Sonar into your ANT build process.
Sonar integrates Findbugs (and checkstyle and PMD) and you can centrally configure it to fail the build against any set of criteria using it's build breaker plugin. See:
How do I make Hudson/Jenkins fail if Sonar thresholds are breached?
Upvotes: 2