Jump to content

Apache Ant

100% developed
From Wikibooks, open books for an open world
Apache Ant logo
Apache Ant logo

Apache Ant (or simply Ant) is an XML-based build scripting language used heavily by the Open Source community. Ant automates tasks such as compiling source code, building deployment packages and automatically checking dependencies of what items need to be updated in a build set.

Background

This wikibook was based on a presentation created by Dan McCreary for the Minnesota Java Open Source User Group. Dan felt strongly that a gentle introduction to Ant was necessary for new people to easily learn Ant. The existing Ant documentation, although useful for advanced Ant users, did not meet the needs of most beginners. For example in the Apache documentation, advanced concepts such as token filters were placed directly in the introduction for beginners. The introductory material also did not contain full examples with complete sample build files and expected output. Something else was needed. At the same time the introductory material assumed that the reader was familiar with XML. This material covers some of the material you need to know about XML to build Ant scripts.

This wikibook is also designed to work with other XML-related programming wikibooks such as XML Schema and XForms.

Book Structure

This document has an introduction page for people just getting started. Mostly hello world information to get a flavor for what Ant is and how it is used. At the end there are six sections:

Introduction

    1. Background - History and motivation for Apache Ant 100% developed  as of Sept 6th, 2006
    2. Adoption - How and why organizations should adopt Apache Ant 100% developed  as of Sept 6th, 2006
    3. XML Summary - A short review of XML syntax for people that are not familiar with XML. This section can easily be skipped by users that already know about XML file structure. 100% developed  as of Sept 6th, 2006
    1. Installation How to download and install Apache Ant 100% developed  as of Sept 6th, 2006
    2. Testing How to test Apache Ant 100% developed  as of Sept 6th, 2006
    3. Hello World How to run a small ant program that prints "Hello World!" 100% developed  as of Sept 6th, 2006
  1. Core Concepts - Core Terms and Concepts useful to Ant developers
    1. Terminology - Terminology (projects, targets and tasks) 100% developed  as of Sept 6th, 2006
    2. Build File Structure- The structure of a build file 75% developed  as of Sept 6th, 2006
    3. Property Using Properties 100% developed  as of Sept 6th, 2006
    4. Depends Setting up Dependencies 100% developed  as of Sept 6th, 2006
    5. Fileset Using Fileset 100% developed  as of Sept 6th, 2006

Best Practices

  1. Ant Best Practices - Best practices such as how to set up an Ant file 100% developed  as of Sept 6th, 2006
    1. Standard Targets - A list of standard targets such as init and clean 100% developed  as of Sept 6th, 2006
    2. Local Property Files - how to use a local property file 100% developed  as of Sept 6th, 2006
    3. Local File Systems - removing local file system dependencies

Examples

  1. Ant Cookbook - A set of small complete working example programs that demonstrate examples of how to use Apache Ant
    1. Depends - shows how to use the targets depends attribute 100% developed  as of Sept 6th, 2006
    2. Property - shows how to use an Ant property 100% developed  as of Sept 6th, 2006
    3. Fileset - shows how to use an Ant fileset 100% developed  as of Sept 6th, 2006

Ant Tasks that Manipulate XML

XML - how Ant can be used to process XML documents 100% developed  as of Sept 6th, 2006

  1. XMLwellformed - how to use Apache ant to check an XML file for well formedness 100% developed  as of Sept 6th, 2006
  2. XMLvalidate - how to use Apache ant to validate an XML file against an XML Schema 100% developed  as of Sept 6th, 2006
  3. XSLT - how to use Apache ant to run an XML transform 100% developed  as of Sept 6th, 2006
  4. Running Saxon - how to use Apache ant to run Saxon 100% developed  as of March 26th, 2010
  5. Passing Parameters to XSLT - How to pass parameters to an XSLT transform from Apache Ant 50% developed  as of Sept 6th, 2007
  6. XQuery - Using XQuery to transform XML documents 25% developed  as of Feb 26th, 2010
  7. Converting Excel to XML - We use the Apache tika library to convert MS-Excel to XML 50% developed  as of March 4th, 2013
  8. Cleaning up HTML - Use the Apache tika library to clean up HTML 50% developed  as of June 20th, 2013
  9. Converting PDF to XML - We use the Apache tika library to convert PDF to XML 25% developed  as of March 4th, 2013

Ant Tasks that Manipulate eXist

  1. Store XML data - an ant task that will store collection into eXist
  2. Reindex a Collection - an ant task that can reindex an eXist collection
  3. Execute an XQuery - a sample ant task to execute an XQuery
  4. Creating a .xar file - a sample ant task to create an XML archive file for packing modules or apps 25% developed  as of Nov 11th, 2012

References

  1. References - where to get more information on Apache Ant 25% developed  as of Sept 6th, 2006

See also

  • XForms - how to use XForms to create and update XML files to create web form "front-ends" to your Ant scripts
  • XQuery - how to use XQuery to generate and update your Ant build files