Conditional Task on exec failure in Ant

半腔热情 提交于 2019-11-28 00:33:13

Two possiblities

-1-
use some try/catch/finally construct for specific parts of your script
you need some Ant Plugin that provides those features, f.e. =

Flaka
Antcontrib / Antelope

    <trycatch>
     <try>
      <exec .../>
     </try>
     <catch>
      do your cleanup here
      and afterwards don't forget to fail
      </fail message="......."/>
     </catch>
      optionally you may use a finally section also
     <finally>
      ..
     </finally>
   </trycatch>

-2-
use a buildlistener for the whole script ( BUILD SUCCESSFUL, BUILD FAILED )

Kev Jackson has a nice example of an exec-listener in his presentation, = http://people.apache.org/~kevj/ossummit/extending-ant.html (the sources of the exec-listener are included in the slides)

You're able to kick off specific tasks depending on the build result after your build has finished

<!-- taskcontainer -->    
<exec-listener onSuccess="true|false">
..

 your stuff goes here 
..
</exec-listener>

Ant contrib has the concept of a try-catch-finally. However this is a finally for a particular block, not for the entire script.

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