Home > Why Ant? > Why Ant?

Why Ant?

 

 

Imagine that you are working on a large project. The project is a Java project and consists of many .java files. It consists of classes that are dependent on other classes and classes which are stubs or drivers, they are situated in multiple directories and the output files must go into multiple directories too. Suppose you have to perform obvious operations with the .java files as:-

  • Compile the .java files.
  • Put the .class files in a directory.
  • Put the .class files in a .jar.
  • Put all the html/jsp/css and other web files in one directory and package them in .war
  • Package all the third party libraries and dependancies into another .jar
  • Package all the .jars, .wars into .ears for deployment
  • Clean all the directories before every use so that you get fresh compiled versions or packaged structures.

Suppose you are coordinating all of this manually or using some other build utility which doesn’t do what you want it to (which is automate it exactly), then many hours are spent changing directories compiling individual files and so on. All these above operations fall under building and/or deploying a project. Now, imagine if there was a tool that could alleviate the stress and hassle you are experiencing and automate the complete process. Such a tool exists and its called ANT. Before Ant, building and deploying Java applications required a hodgepodge of platform-specific scripts, makefiles, proprietary IDEs, or manual processes. Now, nearly every open source Java project uses Ant. A great number of companies use Ant for internal projects as well.

Ant (originally an acronym for Another Neat Tool), is a java-based build tool with special support for the Java programming language but can be used for just about everything. In theory, it is kind of like make, without make‘s wrinkles. Ant automates software build processes. It is similar to Make but is implemented using the Java language, requires the Java platform, and is best suited to build Java projects.

 

Few of Ant’s features:

  • Ant is platform-independent and hence Cross-platform.
  • It is written purely in Java.
  • Ant is particularly good at automating complicated repetitive tasks and thus is well suited for automating standardised build processes.
  • Ant accepts instructions in the form of XML documents thus is extensible and easy to maintain.
  • More popular than ‘make’ for building Java projects
  • Updated and improved regularly
  • Straightforward XML syntax
  • Plug-in oriented architecture encourages expansion
  • Directly supported by some IDEs (with more coming)
  • Free and open source

 

Why another build tool when there is already make, gnumake, nmake, jam, and others?

Because all those tools have limitations that Ant’s original author(James Duncan Davidson) couldn’t live with, when developing software across multiple platforms. Make-like tools are inherently shell-based: they evaluate a set of dependencies, then execute commands. This means that you can extend these tools by using or writing any program for the OS that you are working on; however, this also means that you limit yourself to the OS, or at least the OS type, such as Unix, that you are working on.

Ant is different. Instead of a model where it is extended with shell-based commands, Ant is extended using Java classes. Instead of writing shell commands, the configuration files are XML-based, calling out a target tree where various tasks get executed. Each task is run by an object that implements a particular Task interface.

One of the primary aims of Ant was to solve make’s portability problems. In a Makefile the actions required to create a target are specified as shell commands which are specific to the current platform, usually a Unix shell. Ant solves this problem by providing a large amount of built-in functionality which it can guarantee will behave identically on all platforms. Ant has also made it trivial to integrate JUnit tests with the build process, so its easy for willing developers to adopt test-driven development, and even Extreme Programming.

 

Links:

http://ant.apache.org/

 

Note: Refer to other posts in Ant category for further knowledge.

 

 

Advertisements
Categories: Why Ant? Tags: , , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: