Blog Entry

Installation of Ant on OS X

Recently at work, I had to perform the task of setting up Ant on my PowerBook, and I was not satisfied with the tutorials I found online. When I finished setting up everything, I wanted to record the entire procedure for my own sake and also for people who need it. At this point, if you don’t know what is Ant, you can probably stop reading further. Most likely you will not need the knowledge that I am about to share. Of course, if you already know how to do this, then please don’t waste your time.

Before I get into step-by-step instruction, you need to download Ant. and I am assuming you saved it on your desktop. Next, open you Terminal and type the following commands:

  1. cd ~/Desktop
  2. sudo sh
  3. mv apache-ant-1.6.5-bin.zip /usr/local/
  4. cd /usr/local/
  5. unzip apache-ant-1.6.5-bin.zip
  6. chown (your account name):(your account name) apache-ant-1.6.5
  7. ln -s apache-ant-1.6.5 ant

Now, let me explain what each line of command means:

  1. Navigate to the Desktop folder where you saved the zip file.
  2. Authenticate as root/superuser, you will need to type your password to complete the authentication.
  3. Move the Ant zip file to the directory /usr/local.
  4. Navigate to directory /usr/local. You can execute ls command to list the content of the current directory just to verify the zip file is here.
  5. Unzip the zip file (pretty obvious).
  6. Change the ownership of the expanded directory to your regular account, so in the future you can modify the Ant folder without authenticating as root again.
  7. Create a link or alias, this step is optional. After the creation of this link, you can refer to Ant directory as /usr/local/ant, instead of /usr/local/apache-ant-1.6.5.

To test whether everything was done correctly, you can open a new Terminal window, and type /usr/local/ant/bin/ant. You should be able to execute Ant if everything is correct. Last thing we need to do is to set up our account so we can simply type Ant instead of this long command. After all, we are all too lazy to type few more characters.

Assuming the default shell of your Terminal is bash; make sure the following lines are in the bashrc file. You can find the file under /etc.

  1. export ANT_HOME=/usr/local/ant
  2. export PATH=${PATH}:${ANT_HOME}/bin

That’s it. To test it, quit all your Terminal windows, and then re-open a new one, type ant, you should see an error message complaining that build.xml does not exist. Done! I hope this is helpful to someone.

Readers' Comments

91 responses from the opinionated mass...

Trackbacks/Pingbacks

  1. graemehunter.co.uk » Blog Archive » links for 2008-10-01
  2. Getting started with JRuby on Rails on OS X - casperfabricius.com
  3. anilmakhijani.com » Compiling a Flowplayer Plugin on Mac OS X
  4. Building Netbeans from Source under OS X 10.6 | Pablumfication
  5. Learning Bit by Bit: Week 1; Installations on OS X 10.6 » Adventures in Science - jannae@itp

Leave a Comment

Be respectful and courteous to each other, be relevant with your comment. Offensive comments will be removed!

Allowed XHTML Tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>