World Library  
Flag as Inappropriate
Email this Article

Apache Ant

Apache Ant (Another Neat Tool)
Apache Ant Logo
Developer(s) Apache Software Foundation
Initial release July 2000 (2000-07)
Stable release 1.9.6 / July 2, 2015 (2015-07-02)
Written in Java
Operating system Cross-platform
Type Build tool
License Apache License 2.0

Apache Ant is a software tool for automating software build processes. It originally came from the Apache Tomcat project in early 2000. It was a replacement for the unix make build tool, and was created due to a number of problems with the unix make.[1] 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 uses Makefile format. By default the XML file is named build.xml.

Ant is an Apache project. It is open source software, and is released under the Apache License.


  • History 1
  • Extensions 2
  • Example 3
  • Portability 4
  • Limitations 5
  • See also 6
  • References 7
  • Bibliography 8
  • External links 9


Ant ("Another Neat Tool"[2]) was conceived by James Duncan Davidson while preparing Sun's reference JSP/Servlet engine, later Apache Tomcat, for release as open source. 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; so Ant was created as a simple platform-independent tool to build Tomcat from directives in an XML "build file". Ant (version 1.1) was officially released as a stand-alone product on July 19, 2000.

Several proposals for an Ant version 2 have been made, such as AntEater by James Duncan Davidson, Myrmidon by Peter Donald and Mutant by Conor MacNeill, none of which were able to find large acceptance with the developer community.[3]

At one time (2002), Ant was the build tool used by most Java development projects.[4] For example, most open source Java developers include build.xml files with their distribution.

Because Ant made it trivial to integrate JUnit tests with the build process, Ant made it easy for willing developers to adopt test-driven development, and even Extreme Programming.


WOProject-Ant[5] is just one of many examples of a task extension written for Ant. These extensions are put to use by copying their jar files into ant's lib directory. Once this is done, these extension tasks can be invoked directly in the typical build.xml file. The WOProject extensions allow WebObjects developers to use ant in building their frameworks and applications, instead of using Apple's Xcode suite.

Antcontrib[6] provides a collection of tasks such as conditional statements and operations on properties as well as other useful tasks.[7][8] implements tasks and types for networking, Swing user interfaces, JSON processing and other.

Other task extensions exist for Perforce, .Net, EJB, and filesystem manipulations, just to name a few.[9]


Below is listed a sample build.xml file for a simple Java "Hello, world" application. It defines four targets - clean, clobber, compile and jar, each of which has an associated description. The jar target lists the compile target as a dependency. This tells Ant that before it can start the jar target it must first complete the compile target.


Within each target are the actions that Ant must take to build that target; these are performed using built-in tasks. For example, to build the compile target Ant must first create a directory called classes (which Ant will do only if it does not already exist) and then invoke the Java compiler. Therefore, the tasks used are mkdir and javac. These perform a similar task to the command-line utilities of the same name.

Another task used in this example is named jar:

This Ant task has the same name as the common Java command-line utility, JAR, but is really a call to the Ant program's built-in JAR/ZIP file support. This detail is not relevant to most end users, who just get the JAR they wanted, with the files they asked for.

Many Ant tasks delegate their work to external programs, either native or Java. They use Ant's own and tasks to set up the command lines, and handle all the details of mapping from information in the build file to the program's arguments and interpreting the return value. Users can see which tasks do this (e.g. , , , ), by trying to execute the task on a system without the underlying program on the path, or without a full Java Development Kit (JDK) installed.


One of the primary aims of Ant was to solve Make's portability problems. The first portability issue in a Makefile is that the actions required to create a target are specified as shell commands which are specific to the platform on which Make runs. Different platforms require different shell commands. Ant solves this problem by providing a large amount of built-in functionality that is designed to behave the same on all platforms. For example, in the sample build.xml file above, the clean target deletes the classes directory and everything in it. In a Makefile this would typically be done with the command:

rm -rf classes/

rm is a Unix-specific command unavailable in some other environments. Microsoft Windows, for example, would use:

rmdir /S /Q classes

In an Ant build file the same goal would be accomplished using a built-in command:


A second portability issue is a result of the fact that the symbol used to delimit elements of file system directory path components differs from one platform to another. Unix uses a forward slash (/) to delimit components whereas Windows uses a backslash (\). Ant build files let authors choose their favorite convention: forward slash or backslash for directories; semicolon or colon for path separators. It converts each to the symbol appropriate to the platform on which it executes.


  • Ant build files, which are written in XML, can be complex and verbose. The complex structure (hierarchical, partly ordered, and pervasively cross-linked) of Ant documents can be a barrier to learning. The build files of large or complex projects can become unmanageably large. Good design and modularization of build files can improve readability but not necessarily reduce size. Other build tools, such as Gradle or Maven, use more concise scripts at the expense of generality and flexibility.
  • Many of the older tasks—the core ones that are used every day, such as , and —use default values for options that are not consistent with more recent versions of the tasks. Changing those defaults would break existing Ant scripts.
  • When expanding properties in a string or text element, undefined properties are not raised as an error, but left as an unexpanded reference (e.g. ${}).
  • Ant has limited fault handling rules, and no persistence of state, so it cannot be used as a workflow tool for any workflow other than classic build and test processes.
  • Lazy property evaluation is not supported. For instance, when working within an Antcontrib loop, a property cannot be re-evaluated for a sub-value which may be part of the iteration. (Some third-party extensions facilitate a workaround; AntXtras flow-control tasksets do provide for cursor redefinition for loops.)
  • In makefiles, any rule to create one file type from another can be written inline within the makefile. For example, you may transform a document into some other format by using rules to execute another tool. Creating a similar task in Ant is more complex: a separate task must be written in Java and included with the Ant build file in order to handle the same type of functionality. However, this separation can enhance the readability of the Ant script by hiding some of the details of how a task is executed on different platforms.

There exists a myriad of third-party Ant extensions (called antlibs) that provide much of the missing functionality. Also, the Eclipse IDE can build and execute Ant scripts, while the NetBeans IDE uses Ant for its internal build system. As both these IDEs are very popular development platforms, they can simplify Ant use significantly. (As a bonus, Ant scripts generated by NetBeans can be used outside that IDE as standalone scripts.)

See also


  1. ^ Suereth, Joshua; Farwell, Matthew (2015). SBT in Action: The simple Scala build tool. Manning Publications.  
  2. ^ "Why do you call it Ant? – Apache Ant FAQ". 
  3. ^ MacNeill, Conor. "The Early History of Ant Development". 
  4. ^ Wiley (2002). Java Tools for eXtreme Programming. p. 76. 
  5. ^ "WOProject-Ant – WOProject / WOLips – Confluence". 
  6. ^ "Ant-Contrib". 
  7. ^ "Ant-Contrib Tasks". 
  8. ^ "". 
  9. ^ "Overview of Ant Tasks". 


  • Loughran, Steve; Hatcher, Erik (July 12, 2007). Ant in Action (2nd ed.).  
  • Holzner, Steven (April 13, 2005). Ant – The Definitive Guide (2nd ed.).  
  • Moodie, Matthew (November 16, 2005). Pro Apache Ant (1st ed.).  
  • Bell, Alexis T. (July 7, 2005). ANT Java Notes: An Accelerated Intro Guide to the Java ANT Build Tool (1st ed.).  
  • Hatcher, Erik; Loughran, Steve (August 2002). Java Development with Ant (1st ed.).  
  • Niemeyer, Glenn; Poteet, Jeremy (May 29, 2003). Extreme Programming with Ant: Building and Deploying Java Applications with JSP, EJB, XSLT, XDoclet, and JUnit (1st ed.).  
  • Williamson, Alan (November 1, 2002). Ant – Developer's Handbook (1st ed.).  
  • Matzke, Bernd (September 2003). ANT: The Java Build Tool In Practice (1st ed.).  

External links

  • Official website
  • Apache Ant manual (tasks, types).
  • Apache Ant wiki.
  • WinAnt – Windows installer for Apache Ant.
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.