Hi vivek, have a look at the following class.
Best regards, Maik import java.io.File; import org.apache.tools.ant.*; public class AntExecuterImpl { private String buildFileName; private String executeTarget; private String buildDir = ""; private String property = ""; public void setBuildFileName( String s ) { buildFileName = s; }; public void setExecuteTarget( String s ) { executeTarget = s; }; public void setBuildDir( String s ) { buildDir = s; }; public void setProperty( String s ) { property = s; }; public void execute() { Project project = new Project(); ProjectHelper projectHelper = ProjectHelper.getProjectHelper(); project.init(); project.setUserProperty( "ant.file", new File( buildFileName ).getAbsolutePath() ); // if you want to send a value property to the buildfile: project.setProperty( "some.property", property ); // or a location property: project.setProperty( "build.dir", new File( buildDir ).getAbsolutePath() ); projectHelper.parse( project, new File( buildFileName ) ); project.addBuildListener( createLogger() ); project.executeTarget( executeTarget ); } 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; } } On Wednesday 19 January 2005 19:22, softgnostics k wrote: > Hi all, > > I am newbie to ant and have one query. My application has a new > menu.This menu creates a build.xml Ant file. Now, when this menu is > invoked, its action should call Ant build, so that the build.xml will > do what is necessary. > > How can I do it? That is, how to call the Ant via java? Is there any > way to use an Ant object? > > Thanks in advance > > vivek. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Maik D o b r y n ____________________________________________ Email : [EMAIL PROTECTED] ____________________________________________ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]