Skip to content

Ant Best Practices: Prefer a single buildfile

This is the third post in my series about Eric M Burke’s Top 15 Ant Best Practices from December 2003. Today’s practice is “Prefer a single buildfile”. To paraphrase Eric, it’s easier to understand a single file rather than a clever hierarchy of files. Having presided over several multi-file builds, I’m only too aware that you can easily hang yourself. On the other hand, sometimes it makes sense to extract something to a different file to achieve a separation of concerns.

If you are trying to map complex dependencies across many build files, or do amazing things in Ant or Nant, then perhaps you need to try and simplify things in your project. I once worked on a project where the frontend was written by my team, and the backend by other. The frontend team branched the work of the backend team, and the backend team kept on trucking with their work. I came to the belated conclusion that we had fallen prey to Conway’s Law; really we had one project, and we should have written it like that. The build on that project was a nightmare: two projects pretending they were free agents, but in reality hopelessly dependent on each other.

I’m torn on this practice, but I’m going to agree with Eric. Ideally you shouldn’t need multiple files. Though it does keep me in a job.

One Comment

  1. Michael Kloss wrote:

    I really made the same experience. Having multiple build files a couple of years ago, I now prefer more single build files. But I have noticed that a my preference started by having ant macros in place. So it is very easy to have short and clean single build files and macros doing most of the magic part. Just as you often tried to solve with multiple build files. Ok, macros could be seen also as build file but much more easier to maintain in my opinion because these are more general. My five cents, Michael

    Thursday, March 20, 2008 at 11:05 am | Permalink

One Trackback/Pingback

  1. The Ant Best Practices Series — The Build Doctor on Saturday, October 11, 2008 at 10:48 pm

    [...] find out. 1 of 15: Adopt consistent style 2 of 15: Put the build file at the root of your project 3 of 15: Prefer a single buildfile 4 of 15: Provide good help 5 of 15: Provide a clean target 6 of 15: Manage dependencies with Ant 7 [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*