ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Conor MacNeill <co...@cortexebusiness.com.au>
Subject Re: Call Ant within my java application
Date Fri, 25 Jun 2004 04:37:52 GMT
bertrand lancelot wrote:
> Hi all,
> 
> I need to call ANT within my Java application.
> 
> first, I tried to execute the class "org.apache.tools.ant.Main" with
> properties from my application. After ANT starts, the JVM breaks with
> System.exit usage. As a result my application shutdown too!

You should not, in general, use Main to integrate Ant into another 
application. Main is the command line driver for Ant and expects to be 
in control of the VM. This is why it calls System.exit - to pass out the 
result code to the command line.

Main.java does other stuff too that you may not want in an embedded 
situation, such as, for example, redirecting System.Out, System.Err and 
System.In.

There is a comment at the top of Main.java:

  * If you integrating Ant into some other tool, this is not the class
  * to use as an entry point. Please see the source code of this
  * class to see how it manipulates the Ant project classes.

So, the best approach is to write your own driver to embed Ant into your 
application and consider how you are going to so IO redirection, etc.

What is probably true is that some facilities in Main need to be moved 
to a helper class to make them accessible to other "driving" programs. 
Work in this area would be useful.

Conor



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message