Chapter 3. The Buildfile

Building projects with Ant requires you to focus on two things: project organization and the Ant buildfile. Rather than distinct focal points, these subjects are two sides of the same coin; they are closely related and any decision made in the design of one affects the design and implementation of the other. In this chapter, we show how to design a project using Ant to manage the build process, and how to write a buildfile for that project. As we go through the sample project, we explain how we arrive at particular design decisions for the layout of the project, as well as for the various parts of the buildfile. Not every project can fit the model we present, but many can; we hope this exercise will prepare you for writing buildfiles in other development projects.

Before we begin, however, you should understand the features of the buildfile itself. The buildfile is the most important aspect of Ant, and many details need explaining. Your understanding of the buildfile’s use of XML is essential. With this, you will be better equipped to examine the major parts of a buildfile. To that end, we’ll begin our discussion in this chapter with a look at the reasons behind Ant’s use of XML. Then we’ll take the sample project and its corresponding layout and define our build requirements. These elements come together and create our example buildfile.

With the buildfile written, we can examine how Ant reads the buildfile and executes the steps defined within it. You ...

Get Ant: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.