calling an ant task programatically.
2 posts in topic
Flat View  Flat View

Posted By:   yogesh_seth
Posted On:   Friday, July 8, 2005 05:15 PM

how do i run an ant task (i need to run junit task) through JAVA code?


Re: calling an ant task programatically.

Posted By:   ross_perry  
Posted On:   Friday, July 15, 2005 01:19 PM

You need to use the ant lib Project class.
And then configure it.

import org.apache.tools.ant.*;

Project proj = new Project();
//set properties
Properties prop = new Properties();
prop.load( new FileInputStream( "build.properties"));
for( Enumeration en = prop.keys(); en.hasMoreElements(); ) {
String key = ( String) en.nextElement();
proj.setProperty( key, prop.getProperty( key));

ProjectHelper.configureProject(proj, new File dir, "build.xml"));

Re: calling an ant task programatically.

Posted By:   Nick_Maiorano  
Posted On:   Saturday, July 9, 2005 10:26 PM


I don't see the need for doing this as this is best handled using a script file. Anyway, running an ant task is like running any other o/s command: you need to use the Runtime class. More specifically, use the exec method to fork out an o/s process.

About | Sitemap | Contact