我有一个 Ant 目标,它按顺序执行 2 个步骤:
<target name="release">
<antcall target="-compile"/>
<antcall target="-post-compile"/>
</target>
使用上面的脚本,如果“-compile”目标失败,它会立即退出。 “-post-compile”没有机会运行。有没有办法确保即使第一步(-compile)失败也执行第二步(-post-compile)?
如果您使用 ant-contrib (这很常见),您可以使用尝试捕获任务 http://ant-contrib.sourceforge.net/tasks/tasks/trycatch.html并把你的post-compile
调用其finally
元素。
另外,如果你是not使用 ant-contrib,那么你可以使用subant http://ant.apache.org/manual/Tasks/subant.html任务给你打电话compile
目标。subant
has a failonerror
属性,您可以使用它来单独忽略失败的目标。上有很多使用示例任务描述页面 http://ant.apache.org/manual/Tasks/subant.html.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)