Skip to content

Ant Import

May 24, 2006

Usually the projects I do are fairly large lasting over a several months. When I write a build file for a project my usual practice is to take a build file I’ve done in the past as start and bend it fit the new project. The downside is that I get a lot of duplicated builds but since the projects are big and largely independent it tends not to matter much and means I don’t have to worry about changes to a centralised build file effecting old projects.

Recently my work has taken me to writing smaller applications so I thought a more modular approach was in order. One thing I really didn’t want is to find an error and have to fix it in multiple build files. One of the nicer things they added in ant 1.6 was the import task. This task is similar to an include but allows you to override tasks with alternative versions and potentially call the original. This makes creating modular builds a snap.

This is really probably nothing new for most people as ant 1.6 has been out for some time now but it’s really nice being able to create a build file that does everything I need by simply importing a shared build. The overriding allows me to customize things easily making the whole process powerful but still very flexible.

Basically I define a common build file that handles compilation, testing, javadoc and coverage reporting then specialise that by creating another build that specializes it for webapps or libraries depending on the type of project I’m working on.

Add ivy to the mix and you’ve got a great way of splitting your code up into multiple modules and managing the dependencies between them. More on my experiences with ivy later.

From → Build

One Comment
  1. It works too permalink

    Have you tried Maven or Maven 2?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: