Ant Successful, even if Ant Task failed

There should be a simple setup that I am missing, so forgive me, but I have twice noticed that my bad ant tasks do not cause the build to fail. For example:

  • Ant copy if source file does not exist ... BUILD SUCCESSFUL

  • Ant unzip when task reports "cannot write a file" or a similar message ... BUILD SUCCESSFUL

  • Ant exec error, invalid syntax ... BUILD SUCCESSFUL

How can I guarantee that all errors of the ant task will lead to a build failure?

+8
ant
source share
2 answers
  • <EXEC> tasks are not executed by default. You need to enable this with failonerror="true"

  • The failure of the Ant <COPY> task depends on what type of resource set is being used. If you use fileset or patternset , then all missing files are silently ignored . You can force a failure only using the filelist type or the file attribute.

    Therefore you want to use:

     <copy todir="my_dir" file="foo" /> <copy todir="my_dir" flatten="true"> <filelist dir="" files="foo" /> </copy> <copy todir="my_dir" flatten="true"> <filelist dir=""> <file name="foo" /> <file name="bar" /> <file name="zed" /> </filelist> </copy> 
+7
source share

Have you tried the following:

 <copy todir="your/path/details" failonerror="true"> </copy> <zip destfile="your/path/details" whenempty="fail"> </zip> <exec executable="your/path/details" failonerror="true"> </exec> 
+4
source share

All Articles