Wednesday, September 28, 2011

Build Systems and Apache Ant

In this Blog entry I write about my experience learning about build systems in general, and Ant in particular.

Ant Code Katas

Again the "Code Kata" approach deserves praise for its role in learning. Until the last Ant Code Kata (#8) the incremental Kata approach proved itself to be appropriate for learning as success came easily with Katas 1-7, motivating me each time to move to the following task. Here are the simple Ant build scripts I implemented:

1. Ant Hello World (Ant echo task)
2. Ant Immutable Properties (Ant property task)
3. Ant Dependencies (Ant target dependency resolution)
4. Hello Ant Compilation (Ant javac task)
5. Hello Ant Execution (Ant java task)
6. Hello Ant Documentation (Ant javadoc task)
7. Cleaning Hello Ant (Ant delete task)
8. Packaging Hello Ant (Ant zip task, ant copy task)

Learning Ant

I was generally impressed with the wide range of useful tasks that can be accomplished by scripting using Ant. By far the most interesting Kata was the zip task, which required understanding the zip target: name the archive, where to place it, and more generally, learning how to include and exclude files. There are also tasks for setting and referencing a multi element classpath. Ant has several ways to do this. Ant properties are immutable, meaning once set, they can not be changed. Integration with Eclipse was expected: Eclipse has a colored syntax editor for working with Ant scripts, Ant "Run Configuration" editor, a "Run as Ant build" button, and it diplays the value of Ant properties when hovering over them in the editor with your mouse.

Automated Build Systems

I learned that automated build systems offer a low cost way to build software releases, including version(ing), automated running of tools such as javadoc, checkstyle, and findbugs, and can even download tools and libraries. They do not interfere with the developers' choice of IDE. An automated build script can be used to automate and verify the build often, with almost no cost once the script is written. Although build systems are not a substitute for JUnit tests or software reviews, practically every substantial software system uses some sort of automated build system to increase productivity, efficiency, reduce errors, and save time.

No comments:

Post a Comment