Automating build process with apache ant

Why and what is Ant?

Without using ant, building and deploying web applications and other enterprise applications required a series of scripts or manual processes, which often led to mistakes.

Apache ant is a powerful tool for automating software build processes. It is implemented by Apache Foundation using java language, requires the java platform and is best suited for building java projects. However that doesn’t means it restricted to java projects. Dot net project also can use ant to automate the build process (Nant). Ant makes application building process and releasing them across different servers far more efficient and less problematic. Ant is applicable for most integrated development environment (IDE) that uses java.

Ant uses XML to describe the build process and its dependencies. By default the xml file named as build.xml. This makes it really simple for you setup and edit different build processes. Build files in ant are extremely important in a project, must be written in care, and maintain in version control and re-factored periodically, when the project dependencies change.

Best features of Ant technology.

Ant is a powerful, platform independent, open source tool. If you choose to use it, get it to do absolutely everything. Ant can integrate with your source control database such as SVN or SCM, run SQL scripts, change file permissions, Send file across FTP, Zip and Unzip files, compile java files, create jar files, and many more tasks beside this.

The best features of the ant technology can be summarized as below:

Easy to Use: It is not a programming language, based on xml and easy to understand and implement.
Portable and cross platform based: Ant is implemented using java and it makes portable. i.e., it can be run on any platform.
Extended functionality: Ant’s functionality can be extended to any development environment based on java.
Build automation: Ant provides automated build process that is faster and more efficient.
Compilation of source code: Ant can compile source code from a variety of version controls and packaging of the compiled code and resources can also be done.

Ant expects your build file to be called build.xml and builds properties file These files also should be in the root directory of your project. Spend the time to formatting the build file. Since XML is quite verbose, use tabs and line breaks to make the file readable to the human eye. Ant itself does not care if the file looks pretty. But you can bet that you and your team will.

Installing ant on the desktop:

The current version (1.7.1) of ant was released on 27-jun-2008 and it can be downloaded on They are provided many formats (zip, tar etc) and you can download any one from there. I’m explaining how to install ant from zip file here. After complete downloading, unzip the content to the C directory. The path for the ant will be “C:\apache-ant-1.7.0”. Then we have to set some environment variables to get ant to work. Right-click on the “MyComputer” and select “properties”. GF to “Advanced” tab and click on “Environment Variables”. Under environment variables, you have to set following path variables.
Set value “C:\apache-ant-1.7.0” to ANT_HOME variable
Set value “C:\apache-ant-1.7.0\lib” to CLASS_PATH variable
Set value “C:\Java\jdk1.5.0_15” to JAVA_HOME variable
Set value “C:\apache-ant-1.7.0\bin” to PATH variable

That is all you have to do for installing ant. Now you have to check whether the installation process is done properly or not. To do this open the command prompt and run the command C:\>ant (just type ant and hit enter). If the following message is appears, then it indicate that your installation is successful. Ant is properly installed on your system.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s