Cleaning Up Does More Than Keep Things Neat

Q: Our developers are having problems testing the application. For example, two builds with no code changes result in differing behaviors. Technically, this shouldn’t happen, but since the compilation steps are hidden, we’re never sure what’s being built each time. How can we fix this?

Every build should be able to return the project directory to its initial state. This may seem like “common sense,” and, while this rule is followed in most build environments — including Linux’s kernel build, our example in Chapter 2, Ant, and Tomcat — the reasons aren’t always made clear. This pattern stems from three common build goals: distribution of the compiled project, distribution of the source, and testing.

In distributing the compiled project, the build manager desires that only the files needed to install, run, and support the finished product are made available to the end user. This is more for keeping the user’s life simple and easy than for any other reason. The best solution is to have a completely separate space for creating the distribution (e.g., the dist directory). This gives the buildfile one location in which to place distributable components, and one location to clean up when a new distribution is needed.

Distributing the source is similar. Use a separate directory for managing the source to be packaged and distributed. Have one place to copy files and one place to delete files (i.e., one ring to rule them all). This makes more sense ...

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.