wolfbiker1
wolfbiker1

Reputation: 89

Including the spotbugs target in build xml (ant)

excuse me, i struggle again. So the taskdef works fine, but i'm unable to actually work with spotbugs.

<target name="bugs" depends="compile">

    <spotbugs home="${spotbugs.home}"
        output="${spotbugs.output}"
        outputFile="bugs.${spotbugs.output}"
        excludeFilter="${spotbugs.exclude}">
    <sourcePath path="."/>
    <auxClassPath path="."/>
    <fileset dir="." includes="${package}/*.class"/>
</spotbugs>

So I want to check the code with

ant -Dpackage=einstieg bugs

and receive "Problem: failed to create task or type spotbugs". The same pattern I use for checkstyle works perfectly. The taskdefinition points to spotbugs and the needed class - without any error. Any suggestions?

So I think that the point to spotbugs simply doesn't exist. But there exists the suitable file in the /lib directory.

This is how the Taskdefinition looks like:

<!-- spotbugs settings -->
    <property name="spotbugs.home" value="C:/ant/lib"/>
    <property name="spotbugs.output" value="xml"/>
    <property name="spotbugs.exclude"
              value="C:/Users/wolfbiker/Documents/einstieg/exclude_filter.xml"/>
    <taskdef resource="edu/umd/cs/findbugs/anttask/tasks.properties"
             classpath="${spotbugs.home}/spotbugs-ant.jar"/>

Upvotes: 1

Views: 1157

Answers (1)

PowerStat
PowerStat

Reputation: 3819

I think when reading Using the SpotBugs Ant task in detail you will see that your

<property name="spotbugs.home" value="C:/ant/lib"/>

should not point into the ant home where you copied the spotbugs-ant.jar, instead it should point to a spotbugs installation itself - which is not the same as the spotbugs ant-task. So spotbugs must also be installed beside the ant-task.

This also means that you have to change your classpath

<taskdef resource="edu/umd/cs/findbugs/anttask/tasks.properties" classpath="${spotbugs.home}/spotbugs-ant.jar"/>

to point to the spotbugs-ant.jar that you should have been copied to your ant/lib directory.

Upvotes: 1

Related Questions