即使Ant任务失败,Ant也会成功 [英] Ant Successful even when Ant Task fails

查看:79
本文介绍了即使Ant任务失败,Ant也会成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须缺少一个简单的设置,请原谅,但我有两次注意到我的糟糕的ant任务不会导致构建失败.例如:

There must be a simple setting I am missing so forgive me, but I've noticed on two occasions that my bad ant tasks do not cause the build to fail. For example:

  1. 源文件不存在时的蚂蚁副本...成功建立

  1. Ant copy when source file does not exist ... BUILD SUCCESSFUL

当任务报告无法写入文件"或类似消息时,蚂蚁会解压缩……构建成功

Ant unzip, when task reports "can't write file" or similar message ... BUILD SUCCESSFUL

Ant exec错误,语法无效...成功建立

Ant exec error, invalid syntax ... BUILD SUCCESSFUL

如何保证所有蚂蚁任务错误都会导致构建失败?

推荐答案

    默认情况下,
  • <EXEC>任务不会失败.您需要使用failonerror="true"

    • <EXEC> tasks do no fail by default. You need to enable this with failonerror="true"

      Ant <COPY>任务的失败取决于所使用的资源收集类型.如果使用filesetpatternset,则所有丢失的文件都会被静默忽略.您只能通过使用filelist类型或使用参数化的'file`属性来强制失败.

      Failure of the Ant <COPY> task depends on what resource collection type is used. If you use a fileset or patternset, then all missing files are silently ignored. You can force a failure only by using the filelist type or the parameterized 'file` attribute is used.

      因此,您要使用的是:

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

    • 这篇关于即使Ant任务失败,Ant也会成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆