In my case, I need to read a properties file and then get those values to create portlet. The first thing, I have to validate if the file exists in the folder.
1. Fail Task
<fail message="Files are missing.">
<condition>
<not>
<resourcecount count="1">
<fileset dir="." includes="${properties.file.name}"/>
</resourcecount>
</not>
</condition>
</fail>
http://ant.apache.org/manual/Tasks/fail.html The link shows more examples of Fail task.
2. Available Task
<!-- If the file doesn't exist, it will display the message. -->
<if>
<not>
<available file="${properties.file.name}"/>
</not>
<then>
<echo message="${properties.file.name} doesn't exist." />
</then>
</if>
https://ant.apache.org/manual/Tasks/available.html The link shows more examples of Fail task.