Adam Murdoch Myrmidon

Myrmidon is one of the Ant 2 proposals currently in development. You can read more about the goals of Ant 2 here.

Myrmidon is a general-purpose task engine. It contains the basic building blocks for assembling any sort of task-based tool. Ant 2 is an example of such a tool, which could be assembled using the Myrmidon task engine, and a library of build related tasks.

Currently, Myrmidon is a prototype of what a task engine might look. It includes a small set of tasks and data types. We are currently porting many of the Ant 1.x tasks to the Myrmidon task engine.

Some of the differences between Ant 1.x and Myrmidon:

  • Groups of tasks can be assembled into self-describing antlib task libraries. This makes it very easy to distribute and install tasks and data-types.
  • A project can import other projects, and reference their targets.
  • Changes to the property model:
    • Properties and data type references now share the same namespace.
    • Properties are mutable.
    • Properties are scoped into global, local, and parent contexts.
  • Changes to task and data-type API:
    • An interface based API, through which a task interacts with the task engine, and the services it provides.
    • A well-defined object lifecycle.
    • Polymorphic types are supported when objects are configured.
    • Reference handling is handled automatically when objects are configured.
    • Aspects can be used to decorate tasks, to add facilities like logging, error handling, or user preferences.
  • A set of well-defined services and APIs have been introduced, to allow tasks to do their work without depending on other tasks:
    • Execute external commands.
    • Execute other tasks.
    • Manage ClassLoaders and Class-paths.
    • Virtual file system (in progress).
    • Execute Java applications (in progress).
    • ...

First, you will need to fetch the Myrmidon source from CVS. The source can be source in the proposal/myrmidon directory of the Ant source tree. You should check out the jakarta-ant CVS module, as described here.

To build Myrmidon, use the build.xml build script. You will need to use Ant 1.4.1 or later. The default target builds the Myrmidon distribution into the dist directory. The distribution is a ready-to-run installation of Myrmidon.

To run Myrmidon, use one of the following methods:

On Windows and Unix platforms, you can use the ant script in the distribution's bin directory. The following environment variables can be used, but are not required (except on Windows 9x - see below).

VariableDescription
JAVA_HOME The directory that the JDK is installed in.
JAVACMD The command to use to start the JVM. Defaults to java.
ANT_HOME The directory containing the Myrmidon distribution. This must be set when running on Windows 95, 98 or Me.

The Myrmidon distribution includes an executable Jar file, which can be used to run Myrmidon. Use the following command:

prompt> java -jar ant-home/bin/myrmidon-launcher.jar options

Run Myrmidon with the -h command-line option for a list of the command-line options that are available.

The project file format is very similar to that of Ant 1. The root element of the project file must be a <project> element. It can take the following attributes:

AttributeDescriptionDefault Value
basedir The base directory for the project. The directory containing the project file.
default The name of the default target. main
version The project file version that the project is written for. None, must be 2.0

A <project> element can contain the following elements, in the order given below:

Project references allow the project to import, or reference, other projects. A <projectref> element takes the following attributes:

AttributeDescriptionDefault Value
name The name to use to identify the referenced project. Required
location The path to the project file to reference. Required

The targets of a referenced project can be used in the depends list of a target in the referencing project, using the following syntax: project-name->target-name.

Library imports allow the project to import the tasks and data-types from an antlib. An <import> element takes the following attributes:

AttributeDescriptionDefault Value
library The name of the library to import. The ext directory of the Myrmidon distribution is searched for a library file with the given name, and an atl extension. Required
type The type of definition to import. Values include task, and data-type. None
name The name of the type to import. None

If the type and name attributes are not provided, the entire contents of the antlib are imported.

Implicit tasks are run before any of the project's targets are run.

Targets are the same as Ant 1.x.

The following table lists the current set of tasks. You can find example usages of these tasks in the sample project file src/make/sample.ant.

TaskDescription
fail Causes the build to fail.
if Conditionally executes a set of tasks.
load-properties Loads a set of properties from a file.
log Writes a log message.
property Sets a property.
try-catch Runs a set of tasks, with a provided error and clean-up handler.
converter-def Register a type converter. These are used when configuring a task or data-type from attributes.
type-def Register a task or data-type.
import Register the contents of an antlib.