Stefan Bodewig Frequently Asked Questions What is Ant?

Ant is a Java based build tool. In theory it is kind of like "make" without makes wrinkles and with the full portability of pure Java code.

Why do you call it Ant?

According to Ant's original author James Duncan Davidson, the name is an acronym for "Another Neat Tool".

Later explanations go along the lines of "Ants are doing an extremely good job at building things" or "Ants are very small and can carry a weight a dozen times of their own" - describing what Ant is intended to be.

Tell us a little bit about Ant's history.

Initially Ant was part of the Tomcat code base when it was donated to the Apache Software Foundation - it has been created by James Duncan Davidson, who also is the original author of Tomcat. Ant was there to build Tomcat, nothing else.

Soon thereafter several open source Java projects realized that Ant could solve the problems they had with makefiles. Starting with the projects hosted at Jakarta and the old Java Apache project, Ant spread like a virus and now is the build tool of choice for a lot of projects.

In January 2000 Ant was moved to a separate CVS module and was promoted to a project of its own, independent of Tomcat.

The first version of Ant that was exposed a lager audience was the one that shipped with Tomcat's 3.1 release on 19 April 2000. This version has later been referenced to as Ant 0.3.1.

The first official release of Ant as a stand alone product was Ant 1.1 released on 19 July 2000. The complete release history:

Ant Version Release Date
1.1 19 July 2000
1.2 24 October 2000
1.3 3 March 2001
I get checksum errors when I try to extract the tar.gz distribution file. Why?

Ant's distribution contains file names that are longer than 100 characters, which is not supported by the standard tar file format. Several different implementations of tar use different and incompatible ways to work around this restriction.

Ant's <tar> task can create tar archives that use the GNU tar extension, and this has been used when putting together the distribution. If you are using a different version of tar (for example, the one shipping with Solaris), you cannot use it to extract the archive.

The solution is to either install GNU tar, which can be found here or use the zip archive instead (you can extract it using jar xf).

Is Ant supported by my IDE/Editor?

See the section on IDE integration on our external tools page.

Why doesn't (X)Emacs parse the error messages generated by Ant correctly?

Ant adds a "banner" with the name of the current task in front of all messages - and there are no built-in regular expressions in Emacs that would account for this.

You can disable this banner by invoking Ant with the -emacs switch. Alternatively you can add the following snippet to your .emacs to make Emacs understand Ant's output.

How do I include an XML snippet in my build file?

You can use XML's way of including external files and let the parser do the job for Ant:

]> ... &common; ... ]]>

will literally include the contents of common.xml where you've placed the &common; entity.

In combination with a DTD, this would look like this:

]> ]]>
How do I send an email with the result of my build process?

You can use a custom BuildListener, that sends out an email in the buildFinished() method. Will Glozer <will.glozer@jda.com> has written such a listener based on JavaMail, the source is

With a monitor.properties like this

mail.from=Will Glozer build.log=build.log build.failed.notify=true build.failed.email.to=will.glozer@jda.com build.failed.email.subject=Nightly build failed! build.succeeded.notify=true build.succeeded.email.to=will.glozer@jda.com build.succeeded.email.subject=Nightly build succeeded! ]]>

monitor.properties should be placed right next to your compiled BuildMonitor.class. To use it, invoke Ant like

<chmod> or <exec> don't work in Ant 1.3 on Unix

The antRun script in ANT_HOME/bin has DOS instead of Unix line endings, you must remove the carriage return characters from this file. This can be done by using Ant's <fixcrlf> task or something like:

/tmp/foo mv /tmp/foo $ANT_HOME/bin/antRun ]]>