ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Bucanek <>
Subject Re: Running ANt files from Java code
Date Wed, 13 Dec 2000 23:23:55 GMT
At 4:22 PM -0600 12/13/00, Kevin Cummings wrote:
>Does anybody out there know the best way to integrate Ant into a 
>Java application? I am generating a build file dynamically and when 
>I'm done I need to execute the script. I thought the best way to 
>accomplish this would be to tie directly in to the Ant code but I 
>can't find a method that I can call to get all of the necessary 
>events and objects needed to successfully run the build. Also, I 
>need to redirect the output of the build to a JTextArea within our 

I just started with Ant this week, but found this very easy to do. 
I'm writing a simple Swing GUI around Ant, so after the buildmaster 
has choosen the targets and set the properties, the app start a build.

I started with a copy of and just started 
hacking away.  Main does everything you need to do (and then some) to 
find a build.xml file, turn it into a Project, and start building.

Note: The XML stuff isn't really a part of Ant.  It's actually 
ProjectHelper that parses the XML and sets up the Targets, Tasks, and 
Properties in the Project.  Unless you need to keep that intermediate 
XML for some reason, you could just create all of the Task and Target 
objects dynamically, then kick off Ant directly.

Hope that helps,

James Bucanek

View raw message