Buildfile Authoring Issues

The example buildfile we present in this chapter is simple compared to the capabilities Ant presents. Our goal is to show how to take a project, organize the files, and write a buildfile that makes life easier for the developers and project managers. The project and the steps we take are exaggerated and expanded to better demonstrate how we came to the decisions we make concerning the design of the project’s organization and buildfile.

Beyond these first steps, your best path towards writing better buildfiles is experience. This includes both working with buildfiles and writing new ones. Most major open source Java applications now use Ant, giving you a virtual repository of best (and worst) practices. As an exercise, you may wish to take one of those buildfiles and, using this book as a reference, comment them, making note of what you think is happening and why.

The following issues have not yet been mentioned because they’re more workarounds for Ant’s shortcomings than buildfile design guidelines. Ideally, Ant’s developers will refactor the design to eliminate the need for these workarounds.

Magic properties

Some properties are set but never explicitly used in any target or task. Ant’s object model allows any build component to see all of a build’s properties. The lack of an in-buildfile reference for these properties has led to their labeling as magic properties. A good example of a magic property is the build.compiler property for the javac task. No ...

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.