Monday, February 7, 2011

Building ANT

I have used ANT for so many projects in past; It's pretty simple..isn't? Today I thought of building ANT itself, was just curious to know how I can do this.

1) Ant site has svn information to get the latest source code from trunk. I used below URL:

http://svn.apache.org/repos/asf/ant/core/trunk

Once you have source code, your eclipse would look like as shown below.



2) Next step is to build the source code.

Go to the folder where you've checked out ANT and run this command:

build -Ddist.dir=<directory_to_contain_Ant_distribution> dist

For me, It was:


build -Ddist.dir=D:\Project-RND\MyAnt

Once the processing gets over, your folder structure will look like 


In /bin and /lib you will see familiar files like ant.bat, ant.cmd, ant.jar etc.


The /lib however does not contain all the jar files, you usually see when you download ANT binaries. So now lets get those jars.

3) Log on to newly built ANT folder and run below commands

ant -f fetch.xml -Ddest=[option]
where option is one of the following, as described above:
  • system - store in Ant's lib directory (Recommended)
  • user - store in the user's home directory
  • optional - store in Ant's source code lib/optional directory, used if building Ant source code
When I ran the same with dest as ‘system’, I got plenty of new jars created in lib folder, and now your /bin and /lib contains most of the ANT jars to go ahead and start building your project from your newly compiled ANT installation.



ANT document also mention, If you wish to install the build into the current ANT_HOME directory, you can use:
build install    (Windows)
sh build.sh install    (Unix)
Actually this step assumes that before building ANT, you have already an ANT installation in your system and ANT_HOME environment variable points to that location. Now if you want to update that location with this latest build, you just need to type build install on command prompt and current ANT_HOME directory will get updated with newly compiled Ant libraries and binaries. That’s why it mention at the bottom:

Both the install and install-lite targets will overwrite the current Ant version in ANT_HOME. Try running this command (a word of caution, take a back up of your ANT_HOME before running this command)


This is not exhaustive tutorial to build ANT, for that you can check ANT web site.  


Note: I'm using Java 6 on Windows XP for building ANT.


Thanks for reading and get back to me for any queries.

No comments:

Post a Comment