Continuous Integration

Getting to know Ant: Part II

Assuming you read the last post, you should have a basic understanding of projects, targets and tasks. In this post, some different tasks, and try to make a slightly more practical ant script. Suppose our build requires a little bit more complexity than displaying "Hello World." In this case, it has to meet the following requirements:

  1. The file HelloWorld.java must be compiled
  2. HelloWorld.class should include debug symbols.
  3. HelloWorld.class must be zipped

Let's start by creating a basic project skeleton. For right now, we'll only include one target: "build". Remember to save your project in "build.xml".

  1. <project name="HelloBuilder" default="build">
  2. <target name="build">
  3. </target>
  4. </project>

At this point, you've doubtlessly realized that unless we learn new tasks, we will be doomed to writing useless ant scripts forever...

Getting to know Ant: Part I

To me, some of the most fascinating problems are the ones that are only visible in hindsight. The angled measuring cup might be the best example of this. With a standard measuring cup, you have to bend over or lift the cup to see how much of a substance you've measured. On the other hand, the angled measuring cup can be read while standing upright. Yet when asked, most people didn't realize the problem with a normal measuring cup until after having seen the one from Oxo.

In much the same way, we ran across a "hindsight problem" at work: every week one guy had to take an hour or two out of his schedule in order to produce an new build for people to test. At the time it seemed perfectly acceptable. Then came the automated build. Now, in hindsight, it's obvious that we allowed several man weeks of a good engineer's time to go to a complete waste. Not only that, but we wasted the time of several testers in the process as well. The same exact set of instructions could be (and were) used to make every build. No part of the build process required any decision that couldn't be scripted to work faster and more consistently.

In order to once and for all save man-kind from this time-sink (or at least a smaller sub-set of humanity), I'll be doing several posts of the process of creating an build script. Though I'm starting with the basics now, by the end of the series I'll probably spend a little time focusing on how to build Flex and .NET projects without having to require any (expensive) human interaction. Before we dive into code, you'll need to install a Java runtime and Apache Ant. Once you've done that, we'll be ready to start.1

Subscribe to RSS - Continuous Integration