Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Apache Ant 101: Make Java builds a snap

Matt Chapman, Software engineer, IBM
Matt Chapman is an advisory software engineer in the IBM Java Technology Centre in Hursley, U.K. He has spent the last seven years working with Java technology, including Java virtual machine implementations for a variety of platforms, the user interface toolkits Swing and AWT, and, more recently, tooling for the Eclipse platform. Matt has a degree in computer science and is also a Sun-certified Java programmer. You can contact him at mchapman@uk.ibm.com.

Summary:  Whether you're a veteran user of Apache Ant or just starting out with this open source Java-based build tool, this tutorial provides a wealth of information. With Java developer and Ant enthusiast Matt Chapman from the IBM Java Technology Centre, you'll walk through the steps involved in writing a build file for a simple Java project, and then look at some of Ant's other useful functions, including filesystem operations and pattern matching. You'll finish the course by writing our own Java class that extends Ant's functionality.

Date:  17 Dec 2003
Level:  Introductory PDF:  A4 and Letter (360 KB | 32 pages)Get Adobe® Reader®

Activity:  17407 views
Comments:  

Getting started

What is this tutorial about?

In this tutorial, you'll learn about Ant, a build tool for Java TM projects. Ant has quickly become popular among Java developers because of its flexibility and ease of use, so you it owe it to yourself to find out more about it.

You don't need any prior experience with or knowledge of Ant before you proceed. We'll first see the basic structure of Ant build files, and learn how to invoke the tool. We'll walk through the steps involved in writing a build file for a simple Java project, and then look at some of Ant's other useful functions, including filesystem operations and pattern matching. We'll finish by writing our own Java class that extends Ant's functionality.

In the course of the tutorial, we'll show you how to run Ant both from the command line and from within the open source Eclipse IDE. You don't need both environments to try out the examples; you can choose either, or even a different development environment, as long as it supports Ant. If you choose to use Ant from the command line, you will need to follow the installation instructions on the Ant home page (see Resources for a link) if Ant is not installed on your machine already. If instead you decide to use only the Eclipse environment, you don't need to install Ant separately, as it is included with Eclipse. If you don't have it already, you can download Eclipse from Eclipse.org (see Resources ).


Should I take this tutorial?

If you write Java code and you're not already using Ant, then this tutorial is for you. Whether you're currently using a different build tool, or none at all, learning more about Ant will probably encourage you to make the effort to switch to it.

If you are already using Ant, then you might still find something of interest here. Perhaps you find some of Ant's behavior unexpected or difficult to fully understand; this tutorial will help. Or maybe you're familiar with the basics but want to know about advanced topics such as chaining builds together, working with CVS repositories, or writing custom tasks; we'll cover all of these topics here.

Ant is designed primarily for building Java projects, but that's not its only use. Many find it helpful for other tasks, such as performing filesystem operations in a cross-platform way. Also, there are a number of third-party Ant tasks available, and writing a custom Ant task is relatively simple, so it's easy to tailor Ant to a particular application.

1 of 10 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Java technology
ArticleID=131477
TutorialTitle=Apache Ant 101: Make Java builds a snap
publish-date=12172003
author1-email=
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).