Ant遇到错误可以继续吗? [英] Can Ant continue when it encounters an error?

查看:23
本文介绍了Ant遇到错误可以继续吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按顺序执行 2 个步骤的 Ant 目标:

I have an Ant target that executes 2 steps in sequence:

<target name="release">
    <antcall target="-compile"/>
    <antcall target="-post-compile"/>
</target>

使用上面的脚本,如果-compile"目标失败,它会立即退出.-post-compile"没有机会运行.即使第一个(-compile)失败,有没有办法确保执行第二个步骤(-post-compile)?

With the above script, it quits immediately if the "-compile" target fails. "-post-compile" does not get a chance to run. Is there a way to make sure the second step (-post-compile) is executed even if the 1st one (-compile) fails?

推荐答案

如果您正在使用 ant-contrib(这很常见),您可以使用 try-catch 任务 并将您的 post-compile 调用放入其 finally 元素.

If you are using ant-contrib (which is very common), you could make use of the try-catch task and put your post-compile call into its finally element.

此外,如果您使用 ant-contrib,那么您可以使用 subant 任务来调用您的 compile 目标.subant 有一个 failonerror 属性,您可以使用它来单独忽略失败的目标.任务描述页面上有很多使用示例.

Also, if you are not using ant-contrib, then you might use the subant task to call your compile target. subant has a failonerror attribute, which you can use to individually ignore failed targets. Lots of usage examples on the task description page.

这篇关于Ant遇到错误可以继续吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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