Home | Business News | Browse by Publication | X | XML Journal

Ant: an introduction by example: a build tool based on XML, using Java classes.

Publication: XML Journal
Publication Date: 01-MAR-02
Format: Online - approximately 3633 words
Delivery: Immediate Online Access
Full Article Title: Ant: an introduction by example: a build tool based on XML, using Java classes.(Tutorial)

Article Excerpt
Ant is a build tool that provides a platform-independent alternative to shell script--based build tools like make. Developed using Java classes and based on XML, Ant preserves the "write once, run anywhere" Java motto. With Ant's plethora of built-in tasks and easy-to-follow documentation, it doesn't take an Ant guru to begin building with it.

This article introduces the basic concepts of Ant and examines its built-in capabilities that can be used when building and testing J2EE applications in WebSphere. We also demonstrate how to extend Ant's function to interact with IBM WebSphere Application Server.

Ant and XML

The build process for an Ant user's project is defined through an XML buildfile. Since the buildfile is constructed with a common standard, it isn't necessary to learn -- and adhere to -- a new build tool syntax XML also makes the buildfile very readable and self-explanatory. This helps with the learning curve when you're getting up to speed with the project's build process.

Ant can be bundled easily with a software installation since it's supported on all Java-supported platforms and has a simple installation process. For example, code samples and tutorials that accompany application server software can also have Ant buildfiles to simplify their build-and-deploy process.

Ant is task-driven, with each task implemented by a Java class. Since it's based on Java, it's no longer necessary to maintain a buildfile per platform. Ant's configuration file is constructed once and run on any platform.

Ant provides a set of predefined tasks that make it quick and easy to get started. However, Ant isn't limited to these tasks: it's extensible through custom Java classes that implement a common interface. Not only are the tasks extensible, but Ant provides interfaces for creating custom build listeners.

A JAXP XML parser, along with a JDK (Java Developer's Kit), must be installed and configured on the machine that will be running Ant. IfWebSphere Application Server is installed, then both the XML parser and the JDK are already configured. The Ant and the JAXP XML parser installables are downloadable at http://jakarta.apache.org/ ant/index.html. Once downloaded and unpacked, only a few system variables remain to be set up before you can run Ant.

Running with Ant

When installation is complete, Ant is invoked by typing "ant" at a command prompt. Once invoked, Ant will locate a configuration file, build.xml, in the same directory from which it was invoked. By specifying the -find command-line parameter, Ant will attempt to locate the build.xml file from the current directory and, if not found, from each parent directory until the root directory has been searched. The configuration file isn't constrained to the name build.xml. Ant can be pointed to any configuration file using the -buildfile command-line parameter.

The build.xml file is constructed with four main components (the relationship between them is displayed in Figure 1):

1. Project: Each buildfile has one project. The project is a unit of work that defines target(s), which consist of task(s). The project has three attributes: name, default, and basedir. Only the default attribute is required. The name attribute is a descriptive identifier for the...



More articles from XML Journal
A client for testing server-side XML applications: help in speeding up..., March 01, 2002
Transforming XML documents into HTML; stylesheets separate content fro..., March 01, 2002
What's online: www.sys-con.com/xml., March 01, 2002
New series of e-learning courses. (XML News).(Online-learning.com), March 01, 2002
Book on Jabber protocols available. (XML News).(Brief Article), March 01, 2002

Looking for additional articles?
Search our database of over 3 million articles.

Looking for more in-depth information on this industry?
Search our complete database of Industry & Market reports by text, subject, publication name or publication date.

About Goliath
Whether you're looking for sales prospects, competitive information, company analysis or best practices in managing your organization, Goliath can help you meet your business needs.

Our extensive business information databases empower business professionals with both the breadth and depth of credible, authoritative information they need to support their business goals. Whether it be strategic planning, sales prospecting, company research or defining management best practices - Goliath is your leading source for accurate information.