Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Apache Ant
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Java build tool}} {{refimprove|date=July 2020}} {{Infobox software | name = Apache Ant | logo = Apache-Ant-logo.svg | screenshot = | caption = | author = James Duncan Davidson | developer = [[Apache Software Foundation]] | released = {{Start date and age|df=yes|2000|07|19}} | latest release version = 1.10.15 | latest release date = {{Start date and age|2024|08|29}}<ref>{{cite web|url=https://ant.apache.org/antnews.html|access-date=11 December 2024|title=Apache Ant Project News}}</ref> | latest preview version = | latest preview date = | platform = [[Java SE]] | repo = {{URL|https://github.com/apache/ant|Ant Repository}} | programming language = [[Java (programming language)|Java]] | genre = [[Build tool]] | license = [[Apache License 2.0]] }} '''Apache Ant''' is a software tool for [[build automation|automating software build]] processes for Java applications<ref>{{Cite web|title=Apache Ant - Welcome|url=https://ant.apache.org/|access-date=2022-01-25|website=ant.apache.org}}</ref> which originated from the [[Apache Tomcat]] project in early 2000 as a replacement for the [[Make (software)|Make]] build tool of [[Unix]].<ref>{{Cite web|title=Apache Ant - Frequently Asked Questions|url=https://ant.apache.org/faq.html#history|access-date=2022-01-25|website=ant.apache.org}}</ref> It is similar to Make, but is implemented using the [[Java (programming language)|Java]] language and requires the Java platform. Unlike Make, which uses the [[Makefile#Makefiles|Makefile format]], Ant uses [[XML]] to describe the code build process and its dependencies.{{sfn | Moodie | 2005 | loc = Chapter Β§1 Introducing Ant| pp=5-9}} Released under an [[Apache License]] by the [[Apache Software Foundation]], Ant is an [[open-source software|open-source project]]. ==History== Ant ("Another Neat Tool")<ref>{{cite web | url=https://ant.apache.org/faq.html#ant-name | title=Why do you call it Ant? β Apache Ant FAQ}}</ref> was conceived by James Duncan Davidson while preparing [[Sun Microsystems]]'s [[reference implementation|reference]] [[JavaServer Pages|JSP]] and [[Servlet]] engine, later [[Apache Tomcat]], for release as [[Open-source software|open-source]]. A [[proprietary software|proprietary]] version of Make was used to build it on the [[Solaris (operating system)|Solaris]] platform, 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 <ref>Peter Donald. [http://svn.apache.org/repos/asf/ant/core/tags/ANT_13_B1/proposal/myrmidon/src/xdocs/design.html "Myrmidon: The Ant2.0 Proposal"].</ref> and Mutant by Conor MacNeill, none of which were able to find large acceptance with the developer community.<ref>{{cite web | url=http://codefeed.com/blog/?p=98 | title=The Early History of Ant Development | first=Conor | last=MacNeill| date=4 August 2005 }}</ref> At one time (2002), Ant was the build tool used by most Java development projects.<ref>{{cite book | title=Java Tools for eXtreme Programming | author=Wiley | year=2002 | page=76}}</ref> For example, most open source Java developers included <code>build.xml</code> files with their distribution.{{Citation needed|date=March 2010}} Because Ant made it trivial to integrate [[JUnit]] tests with the build process, Ant allowed developers to adopt [[test-driven development]] and [[extreme programming]]. In 2004 Apache created a new tool with a similar purpose called [[Apache Maven|Maven]]. [[Gradle]], which is similar software, was created in 2008, which in contrary uses [[Apache Groovy|Groovy]] (and a few other languages) code instead of XML. ==Extensions== WOProject-Ant<ref>{{cite web|url=http://www.objectstyle.org/confluence/display/WOL/WOProject-Ant |title=WOProject-Ant β WOProject / WOLips β Confluence |url-status=dead |archive-url=https://web.archive.org/web/20090108131210/http://www.objectstyle.org/confluence/display/WOL/WOProject-Ant |archive-date=2009-01-08 }}<!-- Bot generated title --></ref> is just one of many examples of a task extension written for Ant. These extensions are installed by copying their <code>.jar</code> files into ant's <code>lib</code> directory. Once this is done, these task extensions can be invoked directly in the typical <code>build.xml</code> file. The WOProject extensions allow [[WebObjects]] developers to use ant in building their frameworks and apps, instead of using [[Apple Computer|Apple's]] [[Xcode]] suite. <code>Antcontrib</code><ref>{{cite web | url=http://ant-contrib.sourceforge.net | title=Ant-Contrib}}</ref> provides a collection of tasks such as conditional statements and operations on properties as well as other useful tasks.<ref>{{cite web | url=http://ant-contrib.sourceforge.net/tasks/tasks/index.html | title=Ant-Contrib Tasks}}</ref>{{sfn | Moodie | 2005 | loc = Chapter Β§10 Writing Custom Tasks - Using Third-Party Custom Tasks | pp=266-267}} <code>Ant-contrib.unkrig.de</code><ref>{{cite web | url=http://ant-contrib.unkrig.de | title=ant-contrib.unkrig.de}}</ref> implements tasks and types for networking, [[Swing (Java)|Swing]] user interfaces, [[JSON]] processing and other. Other task extensions exist for [[Perforce]], [[.NET Framework]], [[EJB]], and filesystem manipulations.<ref>{{cite web | url=https://ant.apache.org/manual/tasksoverview.html | title=Overview of Ant Tasks}}<!-- Bot generated title --></ref> ==Example== A sample <code>build.xml</code> file is listed below for a simple Java "Hello, world" application. It defines four targets - <code>clean</code>,{{sfn | Moodie | 2005 | loc = Chapter Β§5 Building a Project - Assembling the project - Manipulating the File Location | pp=121-125}} <code>clobber</code>, <code>compile</code> and <code>jar</code> , each of which has an associated description. The <code>jar</code> target lists the <code>compile</code> target as a dependency. This tells Ant that before it can start the <code>jar</code> target it must first complete the <code>compile</code> target. <syntaxhighlight lang="xml"> <?xml version="1.0"?> <project name="Hello" default="compile"> <target name="clean" description="remove intermediate files"> <delete dir="classes"/> </target> <target name="clobber" depends="clean" description="remove all artifact files"> <delete file="hello.jar"/> </target> <target name="compile" description="compile the Java source code to class files"> <mkdir dir="classes"/> <javac srcdir="." destdir="classes"/> </target> <target name="jar" depends="compile" description="create a Jar file for the application"> <jar destfile="hello.jar"> <fileset dir="classes" includes="**/*.class"/> <manifest> <attribute name="Main-Class" value="HelloProgram"/> </manifest> </jar> </target> </project> </syntaxhighlight> 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 <code> compile </code> target Ant must first create a directory called <code>classes</code> (which Ant will do only if it does not already exist) and then invoke the Java compiler. Therefore, the tasks used are <code>mkdir</code> and <code>javac</code>. These perform a similar task to the command-line utilities of the same name. Another task used in this example is named <code>jar</code>: <syntaxhighlight lang="xml"> <jar destfile="hello.jar"> </syntaxhighlight> 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 {{tag|exec|open}} and {{tag|java|open}} 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. {{tag|csv|open}}, {{tag|signjar|open}}, {{tag|chmod|open}}, {{tag|rpm|open}}), 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. ==Portability== Ant is intended to work with all systems for which Java runtimes are available. It is most commonly used with [[Microsoft Windows|Windows]], [[Linux]], [[macOS]] and other [[Unix]] operating systems but has also been used on other platforms such as OS/2, OpenVMS, [[Oracle Solaris|Solaris]], HP-UX.<ref> Apache Ant Manual. Section [https://ant.apache.org/manual/install.html#sysrequirements "System Requirements"]. </ref> Ant was designed to be more portable than Make.{{sfn | Moodie | 2005 | loc = Chapter Β§1 Introducing Ant| pp=5-9}} Compared to Make, Ant uses less platform-specific [[operating system shell|shell]] commands. Ant provides built-in functionality that is designed to behave the same on all platforms. For example, in the sample <code>build.xml</code> file above, the ''clean'' target deletes the <code>classes</code> directory and everything in it. In a Makefile this would typically be done with the command: rm -rf classes/ <code>[[rm (Unix)|rm]]</code> 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: <syntaxhighlight lang="xml"> <delete dir="classes"/> </syntaxhighlight> Additionally, Ant does not differentiate between forward slash or backslash for directories and semicolon or colon for path separators. It converts each to the symbol appropriate to the platform on which it executes. ==Limitations== {{original research|section|date=September 2011}} *Ant build files, which are written in [[XML]], can be complex and verbose, as they are hierarchical, partly ordered, and pervasively cross-linked. This complexity 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. *Many of the older tasks, such as {{tag|javac|open}}, {{tag|exec|open}} and {{tag|java|open}}β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. <code>${unassigned.property}</code>). *Ant has limited fault handling rules. *[[Lazy evaluation|Lazy property evaluation]] is not supported. For instance, when working within an Antcontrib {{tag|for|open}} 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, one 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 exist third-party Ant extensions (called ''antlibs'') that provide much of the missing functionality. Also, the [[Eclipse (software)|Eclipse]] [[integrated development environment]] (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== *[[Build automation]] **[[List of build automation software]] *[[Apache Jelly]], a tool for turning XML into executable code *[[Apache Ivy]], a dependency manager which integrates tightly with Ant, subproject of Ant *[[Apache Maven]], a project management and build automation tool primarily for Java *[[NAnt]], Ant-like tool targeted at the .NET Framework environment rather than Java *[[Gradle]], a JVM build tool built with Groovy ==References== {{Reflist}} ==Further reading== {{refbegin}} *{{cite book | first1 = Steve | last1 = Loughran | first2 = Erik | last2 = Hatcher | title = Ant in Action | publisher = [[Manning Publications]] | edition = 2nd | pages = 600 | date = July 12, 2007 | isbn = 978-1-932394-80-1 }} *{{cite book | first1 = Steven | last1 = Holzner | title = Ant β The Definitive Guide | publisher = [[O'Reilly Media]] | edition = 2nd | pages = 334 | date = April 13, 2005 | isbn = 978-0-596-00609-9 | url = http://oreilly.com/catalog/9780596006099/ }} * {{cite book | last=Moodie | first=Matthew | title=Pro Apache Ant | publisher = [[Apress]] |edition = 1st | year=2005 | isbn=1-59059-559-9 |url = https://archive.org/details/proapacheant0000mood/page/n1/mode/2up}} *{{cite book | first1 = Alexis T. | last1 = Bell | title = ANT Java Notes: An Accelerated Intro Guide to the Java ANT Build Tool | publisher = [[Virtualbookworm.com Publishing]] | edition = 1st | pages = 268 | date = July 7, 2005 | isbn = 978-1-58939-738-5 | url = http://www.virtualbookworm.com/mm5/merchant.mvc?Screen=PROD&Store_Code=bookstore&Product_Code=antjava }} *{{cite book |first1 = Erik |last1 = Hatcher |first2 = Steve |last2 = Loughran |title = Java Development with Ant |publisher = [[Manning Publications]] |edition = 1st |pages = [https://archive.org/details/javadevelopmentw0000hatc/page/672 672] |date = August 2002 |isbn = 978-1-930110-58-8 |url = https://archive.org/details/javadevelopmentw0000hatc/page/672 |url-access = registration }} *{{cite book | first1 = Glenn | last1 = Niemeyer | first2 = Jeremy | last2 = Poteet | title = Extreme Programming with Ant: Building and Deploying Java Applications with JSP, EJB, XSLT, XDoclet, and JUnit | publisher = [[SAMS Publishing]] | edition = 1st | pages = 456 | date = May 29, 2003 | isbn = 978-0-672-32562-5 | url = http://www.informit.com/store/product.aspx?isbn=0672325624 }} *{{cite book | first1 = Alan | last1 = Williamson | title = Ant β Developer's Handbook | publisher = [[SAMS Publishing]] | edition = 1st | pages = 456 | date = November 1, 2002 | isbn = 978-0-672-32426-0 | url = http://www.informit.com/store/product.aspx?isbn=0672324261 }} *{{cite book |first1 = Bernd |last1 = Matzke |title = ANT: The Java Build Tool In Practice |publisher = [[Charles River Media]] |edition = 1st |pages = [https://archive.org/details/antjavabuildtool0000matz/page/280 280] |date = September 2003 |isbn = 978-1-58450-248-7 |url = https://archive.org/details/antjavabuildtool0000matz/page/280 }} {{refend}} ==External links== {{Wikibooks|Apache Ant}} *{{Official website}} {{Apache Software Foundation}} {{Authority control}} [[Category:Apache Software Foundation projects|Ant]] [[Category:Build automation]] [[Category:Compiling tools]] [[Category:Cross-platform free software]] [[Category:Free software programmed in Java (programming language)]] [[Category:Java (programming language) libraries]] [[Category:Java development tools]] [[Category:Software using the Apache license]] [[Category:XML software]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Ambox
(
edit
)
Template:Apache Software Foundation
(
edit
)
Template:Authority control
(
edit
)
Template:Citation needed
(
edit
)
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Infobox
(
edit
)
Template:Infobox software
(
edit
)
Template:Main other
(
edit
)
Template:Official website
(
edit
)
Template:Original research
(
edit
)
Template:Refbegin
(
edit
)
Template:Refend
(
edit
)
Template:Refimprove
(
edit
)
Template:Reflist
(
edit
)
Template:Sfn
(
edit
)
Template:Short description
(
edit
)
Template:Sister project
(
edit
)
Template:Tag
(
edit
)
Template:Template other
(
edit
)
Template:Wikibooks
(
edit
)