Can Ant continue when it encounters an error?

会有一股神秘感。 提交于 2019-12-07 10:23:21

问题


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

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

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?


回答1:


I think you are looking for

-keep-going (-k)

This will tell Ant to continue building all targets which do not depend on the failed target.




回答2:


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.

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.



来源:https://stackoverflow.com/questions/8583162/can-ant-continue-when-it-encounters-an-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!