I am developing two java programs that run in separate VM's that have a typical server/client relationship. Using ant's parallel/sequential tasks I've been able to get ant to run the server and then the client. I would now like it so that when the client process has stopped, ant kills the server. I've seen this done with custom ant tasks for specific server applications (like TomCat), does any method exist for doing this with generic java processes?
+1
A:
Since you are developing the server application, you can have it listen for a "shutdown" command. Then you can have ant send it the shutdown command when the client exits, something like:
<parallel>
<server .../>
<sequential>
<client ... />
<!-- client has finished, send stop command to server -->
</sequential>
</parallel>
Another option which may work for you is to start the server inside a daemons
element.
<parallel>
<daemons>
<server .../>
</daemons>
<sequential>
<client ... />
</sequential>
</parallel>
This will make the server run in a daemon thread, which will not prevent ant from completing. When ant stops, all daemon threads, including your server, will be terminated.
Jason Day
2010-02-21 15:43:46
Perfect, that is is exactly it.
Sandro
2010-02-27 18:18:16