Return-Path: Mailing-List: contact ant-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list ant-user@jakarta.apache.org Received: (qmail 14294 invoked from network); 13 Dec 2000 23:24:08 -0000 Received: from cx36961-b.chnd1.az.home.com (HELO ?24.16.142.11?) (24.16.142.11) by locus.apache.org with SMTP; 13 Dec 2000 23:24:08 -0000 Received: from [192.0.1.63] by 24.16.142.11 (AppleShare IP Mail Server 6.2.1) id 30610 via TCP with SMTP; Wed, 13 Dec 2000 16:24:05 -0700 Mime-Version: 1.0 X-Sender: Subscriber@alice.gloaming.com Message-Id: In-Reply-To: <5.0.0.25.2.20001213161722.009f92e0@mongoosetech.com> References: <5.0.0.25.2.20001213161722.009f92e0@mongoosetech.com> Date: Wed, 13 Dec 2000 16:23:55 -0700 To: ant-user@jakarta.apache.org From: James Bucanek Subject: Re: Running ANt files from Java code Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N 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 >Application. 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 org.apache.tools.ant.Main 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