October 24, 2003

on autobuilds and Ant

So everyone pretty much agrees that regular automated builds are a good thing. Seeing as I tend to open my big mouth at work and concur with such sentiments, I’ve talked my way into building a system that will:

  • pull the required code from cvs
  • attempt to compile said code
  • if code compiles, attempt to run unit tests
  • calculate various code metrics on the code
  • produce an html report of the results, with links to all the details

Now, first some things about the code base in question:

  • it’s in java, with a build.xml for each ‘project’ (for us, a project = a web site section or a library)
  • each application is consistently laid-out (similiar build targets, directory structure, etc.)

My first stab at this problem resulted in a perl-generated build.xml file that would generate all the necessary targets for a list of applications. (Ant isn’t a programming language - there is no concept of iteration.) This wasn’t good enough for a variety of reasons:

  • how do you handle failures?
  • if a sub-build fails, it can nuke the entire build.
  • how do you only test what compiles?

So, at this point, I did what should have come first, and searched for pre-existing tools that might do the job. What I found was that tools were either a) too limited (can’t run arbitrary build targets), or b) so baroque in their configuration and terse in their documentation as to be useless without a week lost to tweaking.

So I spent the day writing a perl script that will run the autobuild and generate a report on the results. (Aside: it also sends email to the team; I’ve now had to generate mixed/alternative email in both Java and Perl; an instructive experience.) It is, perhaps, not what a Java purist would have done, but I find purity so very tiring when I’ve got work to do.

Posted by Bill Stilwell at October 24, 2003 03:25 PM
Comments

It's not a good sign when the learning curve for a tool exceeds the effort of creating your own from scratch!.
Although I never worked with it from an admin perspective, the last project that I was on used Cruise Control (http://cruisecontrol.sourceforge.net) to automate the build process - and it worked quite nicely once configured... but I have a feeling that it suffers from problem (b) which you described above.

Posted by: Jeff at October 27, 2003 11:04 AM

I can't think of any situation in our build and deployment process where I would want the build to be considered 'successful' if part of the code failed to compile. If part of the code (a sub project) doesn't compile, why bother testing the rest of the code or continuing with the build. This is a failure, pure and simple. This is the whole point of continuous integration with tools like Cruise Control and Ant.

Posted by: Charles at February 17, 2004 10:09 AM

Well, in our situation I wanted all the applications to be tested. If one application fails, why would I want all independent tests to not run? If what you're continuously integrating is one big application, I agree, but if it's really several separate applications (or web site sections, as in our case), I don't think killing all tests is the way to go.

Posted by: Bill Stilwell at February 17, 2004 01:58 PM