Installing ANT on Windows and or Mac OS X

I'm gonna try and cover the two OS's here so be kind.

First things first, goto http://ant.apache.org/bindownload.cgi and download the appropriate archive (zip) file: apache-ant-[VERSION NUMBER HERE]-bin.zip

Then for Windows: Extract the .zip to c:\ant. From the command line set the following environment variables:

set ANT_HOME=c:\ant
set JAVA_HOME=c:\jdk-1.5.0.05
set PATH=%PATH%;%ANT_HOME%\bin
For Mac: Unpack the zip file to /usr/local/ant/. Then from the command line set the following environment variables:
export ANT_HOME=/usr/local/ant
export PATH=${PATH}:${ANT_HOME}/bin

Now open up the Terminal(Mac)/Command line(Win) and just type "ANT" and hit return. You should see:

Buildfile: build.xml does not exist!
Build failed

To demonstrate calling a file we're gonna create a quick build.xml. Create a new text file, enter the following bit of XML and save it as build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="myProject" default="runEcho" basedir=".">
   <target name="runEcho">
      <!-- Simply echo's a message to the screen -->
      <echo message="Is anybody out there"/>
   </target>
</project>

If you are on Windows save this file to the root of c:\ and from the command line run the following

ant -buildfile c:\build.xml

If you are on Mac then just save this to the desktop and from the Terminal run:
ant -buildfile ~/desktop/build.xml
You should now see
Buildfile: {PATH_TO_YOU_BUILD_FILE}build.xml

runEcho:
[echo] Is anybody out there

BUILD SUCCESSFUL
Total time: 0 seconds

That's pretty much it, from here you you are now set to run Ant from the Terminal/Command line so in theory you should be able to schedule tasks etc!

Comments (10) Print Send del.icio.us Digg It! Linking Blogs

3586 Views | Posted At : June 27, 2007 4:23 PM | Posted By : Andy Jarrett
Related Categories: Ant, Eclipse, Rough Guide

Related Blog Entries

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)

Big Mad Kev's Gravatar Andy?............. Go celebrate mate and leave this nerdy stuff alone for a while ;)
# Posted By Big Mad Kev | 6/28/07 6:14 AM
Andy J's Gravatar Don't worry Kev, the alcohol hasn't stopped .. i'm just slowly building up to prepare my body for some abusive drinking come the weekend
# Posted By Andy J | 6/28/07 9:04 AM
Jim Priest's Gravatar If he was a real nerd he would have proposed with a build.xml file :) I'll add this to my wiki!
# Posted By Jim Priest | 6/28/07 12:18 PM
tony petruzzi's Gravatar In my nerd days, I once asked my girlfriend on a date using the Wizard from Microsoft Agent :P

http://www.microsoft.com/msagent/default.asp
# Posted By tony petruzzi | 6/28/07 12:59 PM
Big Mad Kev's Gravatar If Andy was a real nerd he wouldn't be able to approach a girl to start with ;)
# Posted By Big Mad Kev | 6/28/07 1:04 PM
Andy J's Gravatar I did consider building a CFC that would except her answer as a boolean and only return it to me as a true value ... no chance of unexpected bugs then
# Posted By Andy J | 6/28/07 1:38 PM
Critter's Gravatar Anyone know if you can pass in attributes to the build.xml file?
# Posted By Critter | 6/29/07 10:05 AM
Andy J's Gravatar @Critter, easier to explain in a post :o)
http://www.andyjarrett.co.uk/andy/blog/index.cfm/2...
# Posted By Andy J | 6/29/07 10:51 AM
Critter's Gravatar aye.

danke
# Posted By Critter | 6/29/07 11:57 AM
Mason Simon's Gravatar Here's a windows installer for Ant that I made: http://code.google.com/p/winant/
I hope it's useful, and let me know if you'd like to develop it further.
# Posted By Mason Simon | 7/7/07 7:36 AM