Chapter 4. Ant Task

Describes the installation and usage of the Jalopy Ant task. Its authors describe Ant [Link] as a “Java-based build tool. In theory, it is kind of like Make, but without Make’s wrinkles.

Why another build tool when there is already make, gnumake, nmake, jam, and others? Because all those tools have limitations that Ant’s original author couldn’t live with when developing software across multiple platforms. Make-like tools are inherently shell-based—they evaluate a set of dependencies, then execute commands not unlike what you would issue in a shell. This means that you can easily extend these tools by using or writing any program for the OS that you are working on. However, this also means that you limit yourself to the OS, or at least the OS type such as Unix, that you are working on. Makefiles are inherently evil as well. Anybody who has worked on them for any time has run into the dreaded tab problem. "Is my command not executing because I have a space in front of my tab???" asked the original author of Ant way too many times. Tools like Jam took care of this to a great degree, but still have yet another format to use and remember.

Ant is different. Instead of a model where it is extended with shell-based commands, Ant is extended using Java classes. Instead of writing shell commands, the configuration files are XML-based, calling out a target tree where various tasks get executed. Each task is run by an object that implements a particular Task interface. Granted, this removes some of the expressive power that is inherent by being able to construct a shell command such as 'find . -name foo -exec rm {}', but it gives you the ability to be cross platform—to work anywhere and everywhere. And hey, if you really need to execute a shell command, Ant has an <exec> task that allows different commands to be executed based on the OS that it is executing on.”

Installation

Explains the steps involved in getting the Ant task up and running.

System requirements

The Plug-in requires Ant 1.5 or later. See the section called “System requirements” for the basic requirements to run Jalopy.

Installation

The Plug-in comes as an executable Jar Archive (JAR) that contains a graphical setup wizard to let you easily install the software. Wizard installation is recommended and explained in detail in the section called “Wizard Installation”.

If you would rather install the Plug-in manually, you have to decompress and copy the appropriate files into the different application and/or settings folders. To decompress the contents of the installer JAR, you can often use the build-in support of your file manager (e.g. Nautilus) or any other software that can handle the ZIP compression format (e.g. 7Zip, WinZip or Stuffit Expander). If you don’t have access to one of the convenience tools, you might resort to the jar command-line application that ships with your Java distribution.

If you’re upgrading from a prior version and want to keep your settings, first copy or rename the current Jalopy settings directory to match the version number of the new release. For instance, if your current settings directory is C:\Documents and Settings\John Doo\.jalopy\1.9 and you’re about to install Jalopy 1.9.3, either copy the directory contents or rename it to C:\Documents and Settings\.jalopy\John Doo\1.9.3. Wizard installation can perform this step automatically.

The Jalopy Ant task requires two JAR files, the Ant library jalopy-ant-1.9.3.jar and the core engine jalopy-1.9.3.jar. These must be added to the class path. You can do this in a number of ways:

  • Add the two JAR files to the SCM repository and explicitly load the tasks using a class path you set up in the build file. This is often the best approach as there’s no need for any work by the individual developers.

  • Copy the two JAR files from the temporary directory into a private directory and add the directory contents to the path via Ant’s -lib option. You can include this directory in the ANT_ARGS environment variable for automatic inclusion.

  • Copy the two JAR files from the temporary directory into the $HOME/.ant/lib folder below your home directory. The library will be available on all projects which may lead to library version conflicts.

  • Copy the two JAR files from the temporary directory into the $ANT_HOME/lib directory of your Ant installation. The library will be available to all users of a machine on all projects which may lead to library version conflicts.

Please note that you should make sure that no other Jalopy binaries are in the class path. Again you might need to check the global $ANT_HOME/lib directory of your Ant installation, the user specific $HOME/.ant/lib folder and any directories you include with the -lib option when running Ant, and remove any older jalopy-*.jar; entries.