Chapter 1. Getting Started

Build tools are one of the most boring items developers must have available in their development cycle. They aren't sexy, they aren't going to impress your friends, and you'll hardly notice a build tool at all until it's time to redeploy that 1,000-class Java application you've been working on. Then, all the interesting code, killer IDEs, and amazing design patterns aren't worth nearly as much as typing ant and calmly watching your boring build tool handle complicated dependencies, deployment onto multiple servers via FTP and SSH, and log errors. It is here that build tools like Ant truly shine.

At its most basic, all a good build tool does is take source code, compile it, and create a working application. When you're writing a single-class application, this isn't a big deal; in fact, it can be annoying to manage a build system instead of typing javac. But it's a different story when you start working with multiple source files, with multiple dependencies, need to check code out of a central repository automatically, test the code, and deploy it to some remote destination. You can end up with dozens of tasks to complete each time you want to build your application, which is the last thing you want to spend time on when you're already brain-dead from an all-night debugging session. When new members join your team, you'll have to walk through this whole process again, showing them the ropes and hoping they don't break anything in the process. It's for all of these reasons that developers—and especially Java programmers—turn to Ant.

Though there are still powerful alternatives to Ant like make, Jam, Cons, gnumake, and nmake, nothing is as integrated into the Java programming language. Ant is pure Java; you'll find line after line of Java code and .java files if you obtain a source release of the tool. Further, some of the most popular projects in the Java universe are built using Ant; everything from Tomcat to JBoss to Turbine can go from source to binary by typing ant.

Ant's Origins

Ant was originally the brainchild of James Duncan Davidson, and the word Ant stands for "Another Neat Tool," a fact that relatively few developers realize. Ant 1.0 first appeared in March 2000. James' original inspiration was to create a build tool that used a simple XML-based format for build files, as opposed to the shell commands and involved formatting that Makefiles used. Ant caught on rapidly, and newer versions followedAnt 1.1 (July 2000), 1.2 (October 2000), 1.3 (March 2001), 1.4 (September 2001), and 1.5 (July 2003). The version this book uses—version 1.6.1—appeared in February of 2004. Although James Davidson has moved on to work with other build tools, Ant continues to evolve on an almost daily basis.

Ant is an open source, Apache community project, and its home page is at http://ant.apache.org. Because it's an open source project, it's always developing. There are multiple authors, called committers, which can write to Ant's source code repositories. However, officially sanctioned Ant versions don't appear too rapidly, and when they do, they're usually backward compatible enough to make sure your build files aren't broken.

Tip

One notable exception to this practice is Ant 2.0, which may be out sometime in the next year or so. When it does come out, the Apache Ant team plans on releasing an automated migration tool that will translate 1.x build files to Ant 2.0.

Get Ant: The Definitive Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.