Стандартный способ муравья будет выглядеть примерно так =
<target name="check">
<condition property="delbuild">
<available file="${build}" type="dir"/>
</condition>
</target>
<target name="delbuild" depends="check" if="delbuild">
<delete dir="${build}"/>
<!-- .. -->
</target>
Фрагмент с Ant Plugin Flaka , недавней альтернативой antcontrib. Установка в Eclipse как обычно через
Настройки | Муравей | Время выполнения | Глобальные записи | ant-flaka-1.02.-1.02.jar =
<project xmlns:fl="antlib:it.haefelinger.flaka">
<!-- some standalone if construct -->
<fl:when test=" '${build}'.isdir ">
<delete dir="${build}"/>
</fl:when>
<!-- some if/then/else construct -->
<fl:choose>
<!-- if -->
<when test=" '${buildtype}' eq 'prod' ">
<!-- then -->
<echo>..starting ProductionBuild</echo>
</when>
<when test=" '${buildtype}' eq 'test' ">
<!-- then -->
<echo>..starting TestBuild</echo>
</when>
<!-- else -->
<otherwise>
<fl:unless test="has.property.dummybuild">
<fail message="No valid buildtype !, found => '${buildtype}'"/>
</fl:unless>
<echo>.. is DummyBuild</echo>
</otherwise>
</fl:choose>
</project>
вывод с ant -f build.xml -Dbuildtype = prod или
ant -f build.xml -Dbuildtype = prod -Ddummybuild = что угодно
[echo] ..starting ProductionBuild
вывод с typo => ant - build.xml -Dbuildtype = testt
BUILD FAILED
/home/rosebud/workspace/AntTest/build.xml:21: No valid buildtype !, found => 'testt'
вывод с ant -f build.xml -Ddummybuild = что угодно
[echo] .. is DummyBuild