2011-12-20 59 views
4

我有执行序列2个步骤的Ant目标:当Ant遇到错误时可以继续吗?

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

利用上述脚本,如果“-compile”目标失败,立即退出。 “-post-compile”没有机会运行。有没有办法确保即使第一步(-compile)失败,第二步(-post-compile)也会执行?

回答

2

我认为你正在寻找

-keep持续(-k)

这将告诉Ant来继续构建不依赖于失败目标的所有目标。

2

如果您使用的蚂蚁的contrib(这是很常见的),你可以利用的try-catch task,把你的电话post-compile到其finally元素。

另外,如果您使用蚂蚁的contrib是,那么你可能会使用subant任务叫你compile目标。 subant有一个failonerror属性,您可以使用它来单独忽略失败的目标。 task description page上有很多使用示例。