I found this useful answer on StackExchange on how to install Apache Ant on a Mac. Earlier versions of OSX came with Ant preinstalled but not so on my installation of Mavericks. Before we do anything we need to download the Ant files from http://ant.apache.org/. The code snippet below assumes that you download the .tar.gz version, but you can work around it if you have downloaded one of the other versions and know how to extract the archive. Copy and paste the commands below into your terminal session (I did them one by one. Also the lines beginning with a # are comments).
# Let's get into your downloads folder. cd ~/Downloads/ # Extract the folder (If you have already extracted the downloaded archive, skip this step) / tar -xvzf apache-ant-1.8.1-bin.tar.gz # Ensure that /usr/local exists sudo mkdir -p /usr/local # Copy it into /usr/local sudo cp -rf apache-ant-1.8.1-bin /usr/local/apache-ant # Add the new version of Ant to current terminal session export PATH=/usr/local/apache-ant/bin:"$PATH" # Add the new version of Ant to future terminal sessions echo 'export PATH=/usr/local/apache-ant/bin:"$PATH"' >> ~/.profile # Demonstrate new version of ant ant -version
The last line is just to verify that you have successfully installed Apache Ant. And that’s it, you have successfully installed Apache Ant on your Mac.