遇到错误时,Ant可以继续吗?

编程入门 行业动态 更新时间:2024-10-27 22:34:44
本文介绍了遇到错误时,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(这很常见),则可以使用 尝试捕获任务 ,并将您的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可以继续吗?

本文发布于:2023-10-16 00:41:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1495963.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   Ant

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!