tags:

views:

38

answers:

1
+1  Q: 

try finally in ant

Hi,

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?

+3  A: 

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>
madgnome
Thou shall not kill -9. :)
Alexander Pogrebnyak