Ant equivalent of nant.onsuccess / nant.onfailure

2019-07-24 17:30发布

NAnt has two built-in properties, nant.onsuccess and nant.onfailure, for specifying tasks to run on success and failure respectively.

Is there an equivalent in Ant?

3条回答
放荡不羁爱自由
2楼-- · 2019-07-24 18:02

Kev Jackson, gave a neat 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

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

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

your stuff goes here
..
</exec-listener>
查看更多
手持菜刀,她持情操
3楼-- · 2019-07-24 18:02

Although I've marked John McG as the answer (as it's what I've gone with), I've also discovered that it's also possible to build similar functionality using BuildListeners.

查看更多
啃猪蹄的小仙女
4楼-- · 2019-07-24 18:13

I don't think there's an ant equivalent but you could use trycatch (part of ant-contrib)

<trycatch>
  <try>
    <!-- Your code here -->
    <!-- Success message -->
  </try>
  <catch>
    <!-- Fail message -->
  </catch>
</trycatch> 

Hope this helps

查看更多
登录 后发表回答