Author
How to call a build.xml
Meet Gaurav
Ranch Hand
Joined: Oct 08, 2008
Posts: 492
Hi How to to call or execute a build.xml (ant file) from a simple java program.
Jimmy Clark
Ranch Hand
Joined: Apr 16, 2008
Posts: 2187
posted Dec 04, 2008 07:41:00
0
java.lang.Runtime
Ove Lindström
Ranch Hand
Joined: Mar 10, 2008
Posts: 326
You use the Ant.class from the Ant API and load your build.xml using the setAntFile(String fileName) and then use .execute();
Meet Gaurav
Ranch Hand
Joined: Oct 08, 2008
Posts: 492
This is not working...
Tom Johnson
Ranch Hand
Joined: May 11, 2005
Posts: 142
Is the file in the appropriate place? From the Ant docs: public void setAntfile(java.lang.String s)
The build file to use. Defaults to "build.xml". This file is expected to be a filename relative to the dir attribute given.
You can use the following method to set the directory:
public void setDir(
java.io.File d)
The directory to use as a base directory for the new Ant project. Defaults to the current project's basedir, unless inheritall has been set to false, in which case it doesn't have a default value. This will override the basedir setting of the called project.
HTH [ December 05, 2008: Message edited by: Tom Johnson ]
<a href="http://faq.javaranch.com/java/UseCodeTags" target="_blank" rel="nofollow">Use Code Tags!!</a>
Ove Lindström
Ranch Hand
Joined: Mar 10, 2008
Posts: 326
Originally posted by Meet Gaurav: This is not working...
Hey... I pointed you in the right direction... not giving you the whole answer... Yes, you have to set the running directory with obj.setDir("dir-path");
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
Not a beginner's topic. Moving thread.
subject: How to call a build.xml