How to Make Your Rational Project Use Ant for Automatic Build

You can configure your project to use an Apache Ant script to build automatically, rather than with the default Java Builder in Rational Application Developer (RAD). This is valuable when you need a more sophisticated build process, but you still want the efficiency and convenience of an automatic build in the IDE. It’s alo useful if you simply need to trigger additional tasks after a ‘clean’, during a ‘clean’, in the manual build, or in the automatic build.

Here’s how you set it up…

Right-click on your project node in the explorer and select Properties from the context menu.

Select ‘Builders’ in the dialog and then click the ‘New…’ button as shown below…

Then select the Ant Builder and click ‘OK’.

On the Main tab of the builder configuration, click the ‘Browse Workspace…’ button and select your Ant build.xml file.

Next, click on the Targets tab. You’ll be able to choose a target in your Ant script to execute After a ‘Clean’, for the Manual Build, for the Auto Build, or during a ‘Clean’. For one or more of those options, click ‘Set Targets…’ and choose a target in the build script.

When you click OK to dismiss all the open dialogs, you will see your new Ant Builder in the list of builders applied to your project. You can then easily toggle the builder on or off or toggle between the Ant Builder and the default java Builder. It’s a lot more convenient than right-clicking your build file and selecting Run As > Ant Build every time you want to build from your Ant script.

Sounds useful, eh? Here’s just one example use case for this, which I know because it’s one I use myself…

Suppose you have a commons project with a lot of utility classes that are bundled up in a JAR and used in multiple other projects. Using an Ant Builder, you could automatically distribute the modified JAR file to all projects in the workspace that use it.

If you have any little not-so-obvious IDE tips like this, please share in the comments section of this page.