Ant task to run an Ant target only if a file exists?

Mario Ortegón picture Mario Ortegón · Feb 6, 2009 · Viewed 174k times · Source

Is there an ANT Task that would execute a block only if a given file exists? I have the problem that I have a generic ant script that should do some special processing but only if a specific configuration file is present.

Answer

toolkit picture toolkit · Feb 6, 2009

Available and Condition

<target name="check-abc">
    <available file="abc.txt" property="abc.present"/>
</target>

<target name="do-if-abc" depends="check-abc" if="abc.present">
    ...
</target>