Search code examples
fileantbuild-automation

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


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.


Solution

  • 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>