Ant Tutorials

A while ago I thought about writing a book about Ant. I even had a deal organized and I had started work on it. In the end, the deal fell through. I was actually relieved, since I had begun to feel that the workload might be pretty high. I have enough deadlines in my life as it is from work and family that I don’t need any more.

Now that I am blogging, however, I thought I could release the occasional tutorial on Ant. This way I can write bits and pieces as I have time and interest without the worry of meeting deadlines. Also I can mix up advanced and introductory stuff as I like.

So, I have put up my first tutorial on Ant up. It is a very basic introduction to Ant.

Beta Testing

I’ve just uploaded the first beta for Ant 1.5.3. One thing I’ve noticed as Ant has matured and become the standard build tool for Java projects is that the betas do not get as much testing as you might expect based on the so-called "open-source " effect.

These days most bug reports actually come after we make a full release and not during the beta period. My guess is that most people do not bother to try out the betas but feel comfortable upgrading to a release. It seems it is the release that actually triggers the testing phase. The consequence is that each major release has more point releases. You can clearly see this trend in Ant releases over time.

This behaviour, whilst understandable at the individual level is perhaps counter-productive to the user community as a whole. An interesting conundrum. For my part, I rarely use a build of Ant that is more than a few days old.

If you are an Ant user, test the beta now.

Ant 1.5.3

I’ll be building the beta for Ant 1.5.3 early next week. Hopefully we can get some good beta testing on this release. This will probably be the last JDK 1.1 compatible release of Ant.

Is Ant2 Required?

Oliver asks why Ant2 is not required? I know Oliver well (we used to sit in adjacent cubicles) and he likes to ask these curly questions, especially while keeping a straight face. Undaunted, I will attempt an answer here.

To really answer this question we need to agree what Ant2 means or meant. If we are referring to the feature set described on the Ant site then many of those things have already come to pass. Data types, multithreading, conditionals, filtersets, javac facade, etc are all in Ant now. An SSH task has just been added and Ant 1.6 will support XML files with namespaces (there is some way to go on what interpretation Ant might give to a namespace). Over time more will also be coming along. In many ways, therefore, Ant2, especially from a user’s point of view is coming along – it’s just still called Ant 1.x

From an Ant developer’s point of view, however, the internals of Ant, what we refer to as the core, are not drastically different, although not static by any means. Many of the issues we have known about, such as poor core/task separation, poor encapsulation, the classloader hierarchy and package collisions are still there.

The question is how to solve these problems. It is easy to start from a clean sheet of paper and, with the benefit of hindsight, design a new Ant core which can be quite compatible with Ant 1.x. Well maybe easy is bit of an understatement but it can be done and I have in fact done that once. Adoption of such a revolution is quite hard to achieve. It is just too much of a change for people to feel comfortable with. Pushed too hard it could be a community breaker.

So, my conclusion is that evolutionary change is probably the way to go. Joel spolsky’s article is pretty relevant here. Changes need to be achieved in incremental fashion sometimes through the use of what I would call micro revolutions. These might even entail micro breakages in compatability.

So, let me change things a little. Let me define Ant2 as the first Ant release which requires JDK 1.2+ for the core function. So, if we were to take that decision now, Ant 1.6 would be called Ant 2.0.

Is Ant2 required? No, not yet.

Ant coverage with Clover

For the last week or two, I’ve helped out on the Clover project at Cortex. We’ve added a few Ant tasks to make it easier to integrate Clover into build files. Clover 1.1 has now been released so you can check out the features yourself.

One of the things I did while testing Clover was to generate historical coverage reports for Ant. I’ve uploaded the results for the Ant core and also for the complete Ant build.

The total coverage is always a lot lower than the core primarily because the optional tasks do not have many tests and for those that do, I generally don’t have the supporting libraries to be able to run the tests. 53% in the core is not that bad, although I want to use Clover to push that higher for Ant 1.6

I generated a coverage report for the first day of every month over the last two years. It’s quite interesting to look at the coverage improving over time and also the growth in the Ant codebase over time. I’m not sure if the dip at Jan 2002 is a problem in my setup or a real decline. It may be that some tests failed in this period. Failures used to halt the tests which would significantly affect the coverage.

In a future entry I’ll describe how I went about generating the coverage information over time.

I have to say that I love the graphs, mostly because I had to write that code using a process, known at Cortex, as gauntlet programming.