I’m currently working on a project with a relatively large (~2000 line) Ant build file, with several supplemental files. The first thing that’s struck me, is that something about the nature of Ant itself makes people treat it very differently from the code it’s building. Rules concerning consistency, testing, maintainability and even common sense seem to go out the window. Whilst it’s true that Ant doesn’t go out of its way to help us – there is little tool support and the XML syntax is fundamentally unsuited to a program (which is really what an Ant file is) – if developers engaged their brain a little more, they’d make life a little easier for everybody.
I’m going to revisit some of the problems with Ant at a later date, but today I’d like to focus on one particular annoyance – the use of the full stop in naming of targets and properties.
As I see it, there are three ways to use a full stop. Firstly, as a space:
...
Secondly as a way of defining a build hierarchy:
...
...
And finally, seemingly at random:
...
...
The main build file I’m working with has examples of all three. Personally I can accept either of the first two approaches, but please be consistent. In fact, please use the same rigour in creating your build files as you do when coding!
8 Responses to “Ant and the use of the full stop”
2000? *Hardcore*! My biggest is a little over seven hundred lines – that that’s probably half comments.
I’m trying “scons”:http://www.scons.org/ out now, but it’s Java support is leaving a little to be desired. I should probably start by tring to build something small, rather than our existing codebase with the 2000 line ant file π
(Whips out ruler) – our main build file is 2817 lines, including the very occasional comment. Plus we’ve got a few other build files for testing and cvsing.
You should (if possible) try to split this uge thing using subant, import… tasks
We have split some tasks out, but the very nature of spliting stuff out can lead to complexity. We need to rewrite the whole thing to be honest, but will do it bit by bit – we’ll create clean, new sub-ant files which we’ll make calls to, and let the rest of the file remain awful. Trying to clean up a 2000 ant file during active development in one fell swoop is a recipie for disaster
I like to use the period (you Brits can say ‘fullstop’ π for the hierarchy case. For the space case, I prefer hyphens. I avoid the last case.
I kind of like period for hierarchy with camel case for spaces, as this fits with most peoples Java style, and ant is mostly used to build Java after all. Really though, I’d just like things to be consistent π
Take a look at my “blog entry”:http://jroller.com/page/martinpllu/20041217#leafcutter_execute_ant_tasks_from on leafcutter, an API which I wrote to execute Ant tasks from Java code. I find this a better choice than Ant for complex build processes.