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

查看:137
本文介绍了遇到错误时,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"没有运行的机会.有没有办法确保即使第一步(编译)失败了,也要执行第二步(编译后)?

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(这很常见),则可以使用

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,则可以使用 任务描述页面上的许多用法示例.

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天全站免登陆