# Apache Myrmidon - Ant1 Compatibitlity Layer

|  | Apache Myrmidon

Myrmidon

- Introduction
- Get Involved
- Building Myrmidon
- Todo List

User Guide

- Build file
- Virtual File System
- Ant1 Compatibility Layer
- Differences to Ant1
- My First Task

Extending Ant

- Configuration HOWTO
- Converter HOWTO
- Type HOWTO
- ClassLoader HOWTO
- Library HOWTO

Container Design

Overview

> The Myrmidon-Ant1 Compatibility layer works by reusing most of the Ant1 code, with tasks and datatypes being prefixed with "ant1." in build files. Almost all of the main Ant1 tree is included in the compatibility layer antlib. To insulate from changes in the Ant1 tree, Ant1 class files are extracted from a jar, rather than being compiled from scratch.

> Here's how it works: The first time an Ant1 task is encountered, an Ant1 project is created, and stored in the TaskContext under the name "ant1.project". The Ant1 versions of Task and Project have been extended, overriding core behaviour, with Myrmidon-specific behaviour.

> The updated version of Task implements Configurable, receiving it's complete Task Model, and actually setting/adding/creating attributes with the help of the IntrospectionHelper. This process is designed to mimic the Ant1 configuration policy, although not all of the subtle variations of configuration present in Ant1 are handled.

> The updated version of Project will provide hooks into the Myrmidon TaskContext, such as:

> - logging (done)
> - properties (done)
> - references (not yet done)
> - Task defined by <taskdef> (done)

> So at present, properties declared in Ant2 tasks are available to all Ant1 tasks, and vice-versa. However, while a `<ant1.path>` reference works fine in other `<ant1.XXX>` tasks, it's not visible to Ant2 tasks in the same build, and vice-versa.

> The `<taskdef>` task works ok, registering the task with the TypeManager using the "ant1." prefix. Only a couple of DataTypes (Path and Patternset) are working as top-level types, but this should be just a matter of adding references to the Ant1 version of TypeInstanceTask in the descriptor.

> The TransformingProjectBuilder (which is now the default builder for files of type ".xml", applies a transformation stylesheet to the file, prefixing select tasks (all at present) with "ant.". If a version attribute is encountered, the file is not transformed

Using the compatibility layer

> Using Ant1 tasks in a Myrmidon build file

> > If you have a Myrmidon build file (eg with `version="2.0"` on the project element, you can use Ant1 tasks and datatypes by using the "ant1." suffix on the regular element name. Virtually all tasks and datatypes from Ant1.4.1 are available in this way.

> > When declaring a new task using the `<ant1.taskdef>` task, don't prepend "ant1." to the taskname. This will be done automatically by the taskdef task. However, you will need to use the "ant1." prefix in all uses of that task.

> Using an existing Ant1 build file

> > Myrmidon will automatically handle Ant1 build files using the Ant1 Compatibility layer. So, using an Ant1 build file with Myrmidon should be as simple as:

> >     [myrmidon-command] -f ant1-build-file.xml

> > This works as follows: When Myrmidon encounters a ".xml" build file which does not have a `version` attribute on the top-level `project` element, it assumes that it is an Ant1 build file. So all tasks are interpreted as though they are prefixed with the "ant." name prefix.

Building the compatibility layer

> Before building the Ant1 Compatibility layer, you need to build Myrmidon, running the `dist-lite` target of the main build. See the build instructions for more details.

> To build the compatibility layer, simply execute:

>     ant -f ant1compat.xml

> from within the root directory of the Myrmidon source tree.

Copyright © 2000-2002, Apache Software Foundation