so far i have invoked ant script from java. Now the question is, is it possible to resume java execution after the termination of the ant build?
How do i do it?
so far i have invoked ant script from java. Now the question is, is it possible to resume java execution after the termination of the ant build?
How do i do it?
org.apache.tools.ant.Main
'smain()
andstartAnt()
methods call theexit()
method which in turn callsSystem.exit(code)
.The solution (assuming you call one of those methods) is to sub-class
org.apache.tools.ant.Main
and override theexit()
methodCheck out the source of Ant's main class,
org.apache.tools.ant.Main
. You can try to invoke itsmain
orstart
method directly, or copy some of its logic to your application.After those methods finish, your application should continue execution.EDIT:
The answer by Paul Cager is correct, I somehow missed the fact that Ant's
Main
callsSystem.exit()
.Another thing about the
main
/start
/startAnt
methods is that they expect the arguments as an array of strings. This can be handy, but it's not particularly typesafe or object-oriented. To invoke Ant for a given buildfile and target, you can use something like this: