From user-return-34851-apmail-ant-user-archive=ant.apache.org@ant.apache.org Fri Jul 18 22:09:36 2003 Return-Path: Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 19050 invoked by uid 500); 18 Jul 2003 22:09:35 -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 19038 invoked from network); 18 Jul 2003 22:09:35 -0000 Received: from relay.t-intra.de (HELO relay.t-online-com.de) (62.156.147.74) by daedalus.apache.org with SMTP; 18 Jul 2003 22:09:35 -0000 Received: from D2CFT80J (p5080e748.dip0.t-ipconnect.de [80.128.231.72]) by relay.t-online-com.de (SMTPSVC(1.0.0.2)) with ESMTP id AE9B814CAE2; Sat, 19 Jul 2003 01:06:28 +0200 (CEST) Message-ID: <006901c34d70$5cf26050$040200c0@D2CFT80J> From: =?iso-8859-1?Q?Antoine_L=E9vy-Lambert?= To: "Ant Users List" , References: <200307181436.31561.jcampbell@inventa.com> Subject: Re: Embedding Ant... Date: Fri, 18 Jul 2003 23:05:47 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Joseph : here is one class which I wrote to run a part of the official tests of the jar task in ant. What you want to write to embed ant can be something like this. Write a build.xml file somewhere and with the sequence of function calls you see here you can call some targets of your build.xml It is also possible not to write any build.xml and to create your targets and your tasks programmatically, but I do not have an example for that at hand. Cheers, Antoine package com.tonisoft; import org.apache.tools.ant.*; import java.io.File; /** * Created by IntelliJ IDEA. * User: administrator * Date: Jan 21, 2003 * Time: 2:25:50 PM * To change this template use Options | File Templates. */ public class testjartask { public static void main (String [] argv){ //String filename="/dev/testant/build.xml"; String filename="/dev/gnu/ant/jakarta-ant/src/etc/testcases/taskdefs/jar.xml"; StringBuffer logBuffer; StringBuffer fullLogBuffer; Project project=new Project(); logBuffer = new StringBuffer(); fullLogBuffer = new StringBuffer(); project = new Project(); project.init(); project.setUserProperty( "ant.file" , new File(filename).getAbsolutePath() ); ProjectHelper.configureProject(project, new File(filename)); project.addBuildListener(createLogger()); //project.executeTarget("cleanup"); project.executeTarget("test4"); project.executeTarget("testRecreateNewerFileSetup"); project.executeTarget("testRecreateWithUpdateNewerFile"); } private static BuildLogger createLogger() { BuildLogger logger = null; logger = new DefaultLogger(); logger.setMessageOutputLevel(Project.MSG_INFO); logger.setOutputPrintStream(System.out); logger.setErrorPrintStream(System.err); logger.setEmacsMode(false); return logger; } } --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org