Posts Tagged ‘Build’

Ant Primer

September 12, 2009 Leave a comment



apache ant 


Ant Origin:

Ant was conceived by James Duncan Davidson while turning a product from Sun into open source. That product, Sun’s reference JSP/Servlet engine, later became Apache Tomcat. A proprietary version of Make was used to build it on the Solaris Operating Environment, but in the open source world there was no way of controlling which platform was used to build Tomcat. Ant was created as a simple platform-independent tool to build Tomcat from directives in an XML “build file”. From this humble beginning, the tool has gone on to become more widespread than the Tomcat product for which it was created. Ant (version 1.1) was officially released as a stand-alone product on July 19, 2000. Today, Ant is the build tool used by most Java development projects. Most open source developers include build.xml files with their distribution.


Ant Introduction:

In recent years, Open Source tool Ant has become the de facto standard for building Java projects. Like its venerable ancestor Make, Ant controls the steps necessary to compile, package, and arrange the files that make up your development project. Built with Java, Ant has been designed to be easy to use, flexible, and platform independent.

Apache Ant is an Apache Jakarta project. It is open source software, and is released under the Apache Software License. It is a java-based tool for automating software build processes. It is similar to Make but is implemented using the Java language, requires the Java platform, and is best suited to building Java projects. The most immediately noticeable difference between Ant and Make is that, Ant uses XML to describe the build process and its dependencies, whereas Make has its Makefile format. By default the XML file is named build.xml.

All modern Java IDEs integrate with it, most open-source Java projects use it. If you are developing Java software and not using Ant, then chances are you’re doing things the hard way. It’s relatively easy to craft an Ant build file by cutting and pasting pieces from other build files, but we don’t want to get into a situation where maintaining the build process is a full-time job. It is important to understand Ant’s capabilities in order to avoid hacking build files. By understanding Ant’s basic data types, syntax, and properties and applying some simple best practice techniques, the build process can be easily controlled, extended, and reused.

ANT enables you to automate the build deploy process of your server-side Java Web components as well, such as custom tags, servlets, and JSPs. Ant gets its cross-platform support by relying on Java for file access, compilation, and other tasks. Ant is extensible through its support for scripting (Jython and NetRexx, among others), Java custom tasks, and the ability to call OS commands, executables, and shell scripts via an Ant exec task (normally a lastresort measure). Ant makes continuous integration possible for server-side components with its automated build script and integration with JUnit, a unit-testing framework for Java. Read more…

Why Ant?

September 11, 2009 Leave a comment



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 Read more…
Categories: Why Ant? Tags: , , , ,