Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

try finally in ant

Tags:

ant

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 equivalent to try finally). What is the recommended way of doing it?

like image 842
Grzenio Avatar asked Jan 22 '23 02:01

Grzenio


1 Answers

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>
like image 107
Julien Hoarau Avatar answered Apr 10 '23 09:04

Julien Hoarau