Return-Path: Delivered-To: apmail-jakarta-ant-user-archive@apache.org Received: (qmail 9287 invoked from network); 14 Feb 2002 00:29:41 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 14 Feb 2002 00:29:41 -0000 Received: (qmail 9268 invoked by uid 97); 14 Feb 2002 00:29:37 -0000 Delivered-To: qmlist-jakarta-archive-ant-user@jakarta.apache.org Received: (qmail 9252 invoked by uid 97); 14 Feb 2002 00:29:37 -0000 Mailing-List: contact ant-user-help@jakarta.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 ant-user@jakarta.apache.org Received: (qmail 9241 invoked from network); 14 Feb 2002 00:29:36 -0000 Message-ID: From: Paul Cody To: "'Ant Users List'" Subject: RE: Calling Ant from Java: An example please ? Date: Wed, 13 Feb 2002 16:26:20 -0800 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N I would approach this by: (1) Setting up a test case where you can execute the task within your application using a build.xml file. That's a good start. (2) Create the Target and Task objects explicitly and add them to the Project. The ProjectHelper task source code does exactly that in response to SAX events. You're just removing the parse step, but the source code should be instructive. Paul > -----Original Message----- > From: Jay Riddell [mailto:jay@theriddells.org] > Sent: Wednesday, February 13, 2002 4:17 PM > To: Ant Users List; Conor MacNeill > Subject: Re: Calling Ant from Java: An example please ? > > > Thank you all that have responded. . . but I still need help ;-) > > Of all the response so far, the most relevant of which has been > "Conor MacNeill" who quoted some > of Ant's testcases. However, I'd rather not implement it where > it requires the use of an build.xml file. Reasons? > - speed > - need for inclusion of an XML parser in my final distribution. > > Rather, I would like an ALL JAVA, ALL SOURCE CODE, NO EXTRA > JAR solution. > > What this means is that I *REALLY* want to figure out how to > use the ANT > API to run the Javac task. > > Any help in THAT direction would be much appreciated. > > > On 2/13/02 2:11 PM, "Conor MacNeill" > wrote: > > > Jay Riddell wrote: > > > >> Yes, I am TRYING to do that. > >> But I am failing miserably. > >> There are NO EXAMPLES on how to do this; there is only Javadoc > >> on the API itself (with very little extra explanatory text). > >> > >> OK, maybe I am not being specific enough here. > >> > >> Here is the java code that I have written that attempts > >> to compile a "Hello, world" java file: > >> http://home.attbi.com/~theriddells/CompileIt.java > >> > >> And here are the results that I get: > >> http://home.attbi.com/~theriddells/results.txt > >> > > > > You could look at Ant's testcases which contain the following code > > > > protected void configureProject(String filename) { > > logBuffer = new StringBuffer(); > > fullLogBuffer = new StringBuffer(); > > project = new Project(); > > project.init(); > > project.setUserProperty( "ant.file" , new > > File(filename).getAbsolutePath() ); > > project.addBuildListener(new AntTestListener()); > > ProjectHelper.configureProject(project, new File(filename)); > > } > > > > What you would need to do then would be to replace the ProjectHelper > > call with one that creates your targets and tasks, etc. > > > > Conor > > > > > > -- > > To unsubscribe, e-mail: > > > For additional commands, e-mail: > > > > > > -- > To unsubscribe, e-mail: > > For additional commands, e-mail: > > -- To unsubscribe, e-mail: For additional commands, e-mail: