Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 84015 invoked from network); 24 Jan 2005 02:33:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 24 Jan 2005 02:33:52 -0000 Received: (qmail 85281 invoked by uid 500); 24 Jan 2005 02:33:47 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 85228 invoked by uid 500); 24 Jan 2005 02:33:47 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 85215 invoked by uid 99); 24 Jan 2005 02:33:46 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of andy.kriger@gmail.com designates 64.233.184.195 as permitted sender) Received: from wproxy.gmail.com (HELO wproxy.gmail.com) (64.233.184.195) by apache.org (qpsmtpd/0.28) with ESMTP; Sun, 23 Jan 2005 18:33:45 -0800 Received: by wproxy.gmail.com with SMTP id 63so283864wri for ; Sun, 23 Jan 2005 18:33:40 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=BJQgz7Oebt0WmkZ9cKQWP4vwxp7Z5L9N8UFlf2I8Z9/PH1xSTODqJWYU/1x2sXdQ3TZSRrxm8c1b74WXYuyBhJjwdunL572bKNFEBP7NX7LDver3xgfcet/hCgpdpxOPwBkvvHBNdJIKZGIgG5ns2xTe3C2xzOYYteaxbsywDCE= Received: by 10.54.20.21 with SMTP id 21mr27689wrt; Sun, 23 Jan 2005 18:33:40 -0800 (PST) Received: by 10.54.19.11 with HTTP; Sun, 23 Jan 2005 18:33:40 -0800 (PST) Message-ID: <207fa8f050123183335313244@mail.gmail.com> Date: Sun, 23 Jan 2005 21:33:40 -0500 From: Andy Kriger Reply-To: Andy Kriger To: Ant Users List Subject: Re: How can I execute Ant targets from within a Java program? In-Reply-To: <41F454D6.8020505@mdl.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <207fa8f0501230637793f9e82@mail.gmail.com> <41F454D6.8020505@mdl.com> X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Still no luck. I'm including my code and build files to see if that gives anyone ideas. If you comment out the import statement the main method works fine. Here's my main method... public static void main(String[] args) { BuildLogger logger = new DefaultLogger(); logger.setMessageOutputLevel(Project.MSG_INFO); logger.setOutputPrintStream(System.out); logger.setErrorPrintStream(System.out); logger.setEmacsMode(true); ProjectHelper ph = ProjectHelper.getProjectHelper(); Project p = new Project(); p.addBuildListener(logger); p.setUserProperty("ant.home", "/usr/share/ant-core"); p.setUserProperty("ant.version", "1.6.2"); p.setKeepGoingMode(true); p.init(); ph.parse(p, new File("build-test.xml")); } Here's build-test.xml... Test script Here's build-import.xml Imported script On Sun, 23 Jan 2005 17:52:22 -0800, Alexey N. Solofnenko wrote: > You need to set ant.home Java property, not the environment variable, if > you want to launch ANT yourself. > > - Alexey. > > Andy Kriger wrote: > > >I am playing around with executing Ant targets from Java code. > > > >Here's what I am trying to do (based on what I've seen in mailing list posts)... > > > > public static void main(String[] args) { > > ProjectHelper ph = ProjectHelper.getProjectHelper(); > > Project p = new Project(); > > ph.parse(p, new java.io.File("build.xml")); > > System.out.println(p.getBaseDir()); > > System.out.println(p.getDefaultTarget()); > > } > > > >But I get ... > >Exception in thread "main" build.xml:6: Could not create task or type > >of type: description. > > > >The $ANT_HOME env var is set and I have all of the $ANT_HOME/lib dirs > >on my classpath. So, either that's not the way to create an in-memory > >version of a build script that can be called from code or there's > >something more I need to do with my classpath so that the > >ProjectHelper can find all the JARs. > > > >Can anyone point me in the right direction? > > > >thx > >andy > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: user-unsubscribe@ant.apache.org > >For additional commands, e-mail: user-help@ant.apache.org > > > > > > -- > ------------------------------------------------------------------------ > / Alexey N. Solofnenko > home: http://trelony.cjb.net/ > / > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org > For additional commands, e-mail: user-help@ant.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org