开发者

try finally in ant

开发者 https://www.devze.com 2022-12-29 21:23 出处:网络
In my ant script, which runs the end-to-end integration tests, I first start a process, then do some other stuff, then run the tests, and then I need to make sure I kill the process. However, I need t

In my ant script, which runs the end-to-end integration tests, I first start a process, then do some other stuff, then run the tests, and then I need to make sure I kill the process. However, I need to make sure I kill the process even if something fails (so I need an eq开发者_如何学JAVAuivalent to try finally). What is the recommended way of doing it?


You could use Trycatch task from Antcontrib

<trycatch property="error.message">
  <try>
    <echo message="Run integration test..."/>
    <echo message="Start process"/>
    <antcall target="launchTests"/>
  </try>

  <catch>
    <echo message="Integration test failed"/>
  </catch>

  <finally>
    <echo message="Kill the process"/>
    <exec executable="kill -9 ..."/>
  </finally>
</trycatch>
0

精彩评论

暂无评论...
验证码 换一张
取 消