Installing and Using ANT on Mac

Installing and Using ANT on Mac

What is ANT?

Apache Ant is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the build of Java applications. Ant supplies a number of built-in tasks allowing to compile, assemble, test and run Java applications. Ant can also be used effectively to build non Java applications, for instance C or C++ applications. More generally, Ant can be used to pilot any type of process which can be described in terms of targets and tasks.

Installation

Go to http://ant.apache.org, scroll down till you have something similar to this:

* .zip archive: apache-ant-1.9.4-bin.zip [PGP] [SHA1] [SHA512] [MD5]
* .tar.gz archive: apache-ant-1.9.4-bin.tar.gz [PGP] [SHA1] [SHA512] [MD5]
* .tar.bz2 archive: apache-ant-1.9.4-bin.tar.bz2 [PGP] [SHA1] [SHA512] [MD5]

And click on the type of compressed file do you prefer. I choose apache-ant-1.9.4-bin.tar.gz. Download and unzip it to /Applications folder.

Configuration

Now we need to be able to call ant from anywhere. To do that we need to edit this file:

sudo vi /etc/paths

Put ur password if requested

In the last line of that file, added this: /Applications/apache-ant-1.9.4/bin

After this, just save the paths file and we are done. If you try run ant, is going to give you a similar error:

Buildfile: build.xml does not exist!
Build failed

This is only complaining because you need to have a build.xml file where you call the ant with all the tasks available.