What is the Use of Ant Build Tool

Ant is a build tool and is used in build process of softwares.

Now the question is that what is a build process? Build process is used to build the software, which comprises a list of tasks items  required to deploy the software application and make it runnable. A few task items are as:

  • Creating the basic structure for project, which is required for deployment. The structure may vary from project to project or depending upon the type of application
  • Taking the latest checkout of the project files from any source code version system
  • Copying the required set of files to the desired directories. This may include filtering of the files which are not required in deployment, but are required only for development. 
  • Compiling the source code to generate output runnable files
  • Copying the required non-source code files to output folders
  • Generating the documentation by using various tools like Java Doc or PHP Documenter. 
  • Running the test cases on the compiled source code
  • Package the output in required format, like jar, war, ear etc
  • Copy the packaged output to the target directory, like in application directory of web servers
  • Generate the schema in database
  • Run scripts for entering sample data in database
  • Starting/Restarting the server
  • And so on
Build Manager is the person who actually takes the responsibility of whole build process. Now imagine that a build manager needs to perform all of above mentioned tasks, and probably many more in a complex environment, then there are good possibility to have mistake in the process. Moreover it is a boring and non-productive work to spent hours on such activities repeatedly. Suppose in a large project, there is a 50 or more steps to build the software. The build manager may need to spend probably whole day to perform these steps. And if there is any mistake at any step, she needs to repeat the whole process again. There are a lot of task items which are generally repeatable in project build and can be error prone if we do it manually. So in brief, it is a basic requirement for building the software to have a build tool which can be easy to use, configurable like a script file and hence can be changed easily anytime and is extensible enough to include new type of build steps.  

This is where Ant comes in picture as a Build Tool to enable the automation of complete build process. A few features of Ant are: 
  • Ant is quite powerful tool due to large collection of existing libraries which are covering almost all tasks required for building a software.
  • Ant is very configurable because of its XML based definition structure. Ant provides various kind of build tasks as XML tag, which can be used in a XML based build file specifying the required parameters as attribute or sub-elements of XML tags.
  • Ant is extensible as anyone can define a new task and corresponding XML tag by extending the existing core library.
  • Ant can be invoked from any type of script like bat file or shell script etc.
  • Ant is platform independent as it is built using Java, so it can be run on any platform.
  • Ant provides the feature to enable debug information at runtime so it is very easy to debug a Ant Build Script for any possible mistakes
  • Ant is very flexible, as you can make it more configurable by loading the required file system paths and other attributes from property file. 
  • Ant is good in performing very cumbersome tasks as well, like copying all files from one folder to other however leaving all .xml and .properties files. 
  • Ant has support for many latest libraries required for development like Hibernate etc
  • Ant can be used for softwares build in languages other than Java also like PHP. It just need corresponding tasks for these projects and the support of Java on current platform.
This way, Ant is a very important tool for Build Managers to build the software applications. It is equally  important for developers at the time of development, as it saves a lot of time for building and deploying the application while performing the unit level testing. 

For more information of Ant, please refer to its official web site at http://ant.apache.org/

A sample Ant file, sufficient to build a small size project, can be downloaded from http://redmine-jconnector.googlecode.com/svn/trunk/


People who read this post also read :



0 comments:

Post a Comment