File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes How To Run build.xml? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How To Run build.xml?" Watch "How To Run build.xml?" New topic

How To Run build.xml?

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
I have installed the Ant in my machine. And I have
set ANT_HOME=C:\apache-ant-1.5.3-1
set JAVA_HOME=C:\j2sdk1.4.1_02
set PATH=%PATH%;%ANT_HOME%/bin
There is a build.xml file bundled with an application that I have downloaded over the internet. How do I run this build.xml file?
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
ant <yourTarget>
if you have a different XML file with targets, you can use:
ant -f <yourXMLFile> <yourTarget>

I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
Please bear with me. What is MyXMLFile? What is MyTarget? And where should I type the command "ant <MyTarget>"?
The location of this build.xml is located in the NameOfTheApplication/WEB-INF/src folder. It is an application with lots of servlets, jsps, xml files, and property files in different directories.
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Sorry for confusing you
let's start from the beginning. If you located your build.xml file, open it.
you usually have many targets in your file, such as:

This is only an example, notice that you can have many targets. If you can identify one target from your XML file, you can execute it by using:
ant <targetName>
So, I would do:
C:\>ant clean
this target will delete my directory report.
Now, when projects grow you might want to create separate build files, just to organize things better. you can have a build.xml, scripts.xml, reports.xml, etc.
if you do not specify anything (like ant clean), then ant will look for the default XML build file (build.xml). But, if you want to tell Ant to use a different file, you use the -f flag.
C:\>ant -f reports.xml clean
hope it helps
P.S. For simplicity, open a DOS prompt and locate the directory in which your build.xml is placed. In my example, I assumed that build.xml was in my C:\ root.
let us know how it goes
[ September 08, 2003: Message edited by: Andres Gonzalez ]
I agree. Here's the link:
subject: How To Run build.xml?
jQuery in Action, 3rd edition