Ant provides the fail task which allows to fail the build if a condition is not met. For example the following task would check for the existence of a file and if this file is not present the build would fail.
<fail message="PDF file was not created.">
<condition>
<not>
<available file="${pdf.dir}/path/book.pdf" />
</not>
</condition>
</fail>
Or you can check for the number of files generated.
<fail message="Files are missing.">
<condition>
<not>
<resourcecount count="2">
<fileset id="fs" dir="." includes="one.txt,two.txt"/>
</resourcecount>
</not>
</condition>
</fail>