Using Cascading Projects and Buildfiles

Q: We’ve noticed projects like JBoss and Jakarta’s Taglibs do not use the project structure suggested in Chapter 3. Instead, they seem to have multiple buildfiles, one for each subproject. This seems to follow the design discussed when “cascading buildfiles” were mentioned. Just what are these things and how should I use them?

There are two options as to how to build a big project that has many sub-projects. One views the project as a monolithic whole, thus using one buildfile to build everything. The single buildfile defines all the targets necessary to build the project as well as all the data elements and other bits necessary for the entire build. Dependencies between subprojects in a single buildfile can be easily defined and maintained. Packaging and deployment targets can be properly related to every subproject target. The single buildfile describing this project’s build is called a monolithic buildfile.

Some complex projects consist of many segregated subprojects making up one application or framework. The organization is such that each subproject can be built on its own, without worrying much about the other subprojects. The set of buildfiles making up this type of project’s build is called a cascading buildfile.

For small projects or projects with complex dependencies between subprojects, a monolithic buildfile is the ideal choice. For projects that are well-defined and whose subprojects are encapsulated, a cascading buildfile system ...

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.