James McMahon
James McMahon

Reputation: 49659

Getting around redundant dependency limitation in Ant?

The limitation I'm referring to is documented here.

Essentially, in my build script if I want to do a clean, build and then another clean I'm hitting an issue because Ant considers the clean task already complete.

Here is my ant;

<!-- ============================================================= -->
<!-- Clean up directories                                          -->
<!-- ============================================================= -->
<target name="clean">
    <delete dir="${dir.build}"/>
    <delete dir="${dir.src}"/>
</target>

<!-- ============================================================= -->
<!-- Clean up ALL directories                                      -->
<!-- ============================================================= -->
<target name="clean-all" depends="clean">
    <delete dir="${dir.war}"/>
    <delete dir="${dir.docs}"/>
</target>

<!-- ============================================================= -->
<!-- Clean-build target                                            -->
<!-- ============================================================= -->
<target name="build-clean" 
        depends=
        "build,
        clean"
>
</target>

<!-- ============================================================= -->
<!-- Production target, cleans everything prior to build           -->
<!-- ============================================================= -->
<target name="build-production" 
        depends=
        "clean-all,
        build-clean"
>
</target>

Build-production is the target I'm trying to correct, is there anyway to have it clean twice without creating another clean task or explicitly writing clean-all to delete the directories listed in clean?

Upvotes: 0

Views: 138

Answers (1)

Brian Agnew
Brian Agnew

Reputation: 272417

Why not use antcall to explicitly call the clean target again as the final stage of your build-production target ?

Upvotes: 1

Related Questions