Search code examples
javaantbuild

ANT - Run a single target but without dependencies


I know how to run a single target in ANT, but it also checks the "depends" attribute and runs those before the target. Is there a way to prevent this or a way to structure my ANT file so that I can do this more easily?


Solution

  • Create a "withoutdeps" version of the target. If you had

    <target name="A" depends="B">
       ...
    </target>
    

    Change to

    <target name="A" depends="B,AwithoutDeps"/>
    
    <target name="AwithoutDeps">
        ...
    </target>
    

    Now you can call A as normal (which will fire off B then AwithoutDeps) or just call AwithoutDeps explicitly and no deps fired. [Note that "depends" calls the dependencies in order]

    Of course, choose some better names than these ;)