<document>

<properties>
<author email="adammurdoch@apache.org">Adam Murdoch</author>
<title>User Guide</title>
</properties>

<body>

<section name="Project File">

<p>
The project file format is very similar to that of Ant 1.  The root element of
the project file must be a <code>&lt;project&gt;</code> element.  It can
take the following attributes:
</p>

<table>
    <tr><th>Attribute</th><th>Description</th><th>Default Value</th></tr>
    <tr>
        <td>name</td>
        <td>The project name.</td>
        <td>The base-name of the project file, with the extension removed.</td>
    </tr>
    <tr>
        <td>basedir</td>
        <td>The base directory for the project.  The base directory is used
        to resolve all relative file names used in the project file.
        </td>
        <td>The directory containing the project file.</td>
    </tr>
    <tr>
        <td>default</td>
        <td>The name of the default target.</td>
        <td><code>main</code></td>
    </tr>
    <tr>
        <td>version</td>
        <td>The project file version that the project is written for.</td>
        <td>None, must be <code>2.0</code></td>
    </tr>
</table>

<p>
A <code>&lt;project&gt;</code> element can contain the following elements,
in the order given below:
</p>

<ul>
<li><a href="#Project References"><code>&lt;projectref&gt;</code></a></li>
<li><a href="#Library Imports"><code>&lt;import&gt;</code></a></li>
<li><a href="#Implicit Tasks">Implicit tasks</a></li>
<li><a href="#Targets"><code>&lt;target&gt;</code></a></li>
</ul>

<subsection name="Project References">

<p>Project references allow the project to import, or reference, other projects.
A <code>&lt;projectref&gt;</code> element takes the following attributes:</p>

<table>
    <tr><th>Attribute</th><th>Description</th><th>Default Value</th></tr>
    <tr>
        <td>name</td>
        <td>The name to use to identify the referenced project.</td>
        <td>Required</td>
    </tr>
    <tr>
        <td>location</td>
        <td>The path to the project file to reference.</td>
        <td>Required</td>
    </tr>
</table>

<p>
The targets of a referenced project can be used in the <code>depends</code> list
of a target in the referencing project, using the following syntax:
<code><i>project-name</i>-><i>target-name</i></code>.  Here is a simple example:</p>

<source><![CDATA[

<project version="2.0">
    <!-- Reference another project -->
    <projectref name="subproject" location="subproject/build.xml"/>

    <!-- Use the "compile" target from the referenced project -->
    <target name="main" depends="subproject->compile">
        .. do some stuff ..
    </target>
</project>
]]></source>

</subsection>

<subsection name="Library Imports">

<p>Library imports allow the project to import the tasks and data-types from an
antlib.  An <code>&lt;import&gt;</code> element takes the following attributes:</p>

<table>
    <tr><th>Attribute</th><th>Description</th><th>Default Value</th></tr>
    <tr>
        <td>library</td>
        <td>The name of the library to import.  The <code>ext</code> directory
        of the Myrmidon distribution is searched for a library file with
        the given name, and an <code>atl</code> extension.</td>
        <td>Required</td>
    </tr>
    <tr>
        <td>type</td>
        <td>The type of definition to import.  Values include <code>task</code>,
        and <code>data-type</code>.</td>
        <td>None</td>
    </tr>
    <tr>
        <td>name</td>
        <td>The name of the type to import.</td>
        <td>None</td>
    </tr>
</table>

<p>
If the <code>type</code> and <code>name</code> attributes are not provided,
the entire contents of the antlib are imported.
</p>

<p>The following example import the <code>&lt;my-task&gt;</code> task from
the <code>my-tasks</code> antlib.</p>

<source><![CDATA[

<project version="2.0">
  <!-- Import task <my-task> from the 'my-tasks' antlib. -->
  <import library="my-tasks" type="task" name="my-task"/>

  <target name="main">
     <my-task some-prop=".."/>
  </target>
</project>
]]></source>

</subsection>

<subsection name="Implicit Tasks">

<p>Implicit tasks are run before any of the project's targets are run.  Any task
can be used, including <code>&lt;property&gt;</code> and data-type instances.
Implicit tasks can be used to initialise the project.  For example:</p>

<source><![CDATA[

<project version="2.0">

  <property name="some-property" value="some value"/>
  <path id="classpath">
    <fileset dir="lib"/>
  </path>
  <log>Set classpath to ${classpath}</log>

  <target name="main">
    .. do some stuff ..
  </target>

</project>
]]></source>

</subsection>

<subsection name="Targets">

<p>Targets have a similar format to targets in Ant 1.x, though some of the
behaviour is different.  A <code>&lt;target&gt;</code> element takes the
following attributes:</p>

<table>
    <tr><th>Attribute</th><th>Description</th><th>Default Value</th></tr>
    <tr>
        <td>name</td>
        <td>The name of the target.</td>
        <td>Required</td>
    </tr>
    <tr>
        <td>depends</td>
        <td>A comma-separated list of targets that this target depends on.
        This list can contain targets from referenced projects.</td>
        <td>None</td>
    </tr>
</table>

</subsection>

</section>

<section name="Tasks">

    <p>
    Listed below are some of the current set of tasks.  You can find example
    usages of these tasks in the sample project file <code>src/make/sample.ant</code>.
    </p>

    <h3><code>&lt;condition&gt;</code></h3>

    <p>Sets a property if a particular condition is true.  See
    <a href="#Conditions">Conditions</a> for a list of available conditions.</p>

    <h3><code>&lt;fail&gt;</code></h3>
    <p>Causes the build to fail.</p>

    <h3><code>&lt;if&gt;</code></h3>
    <p>Conditionally executes a set of tasks.</p>

    <h3><code>&lt;load-properties&gt;</code></h3>
    <p>Loads a set of properties from a file.</p>

    <h3><code>&lt;log&gt;</code></h3>
    <p>Writes a log message.</p>

    <h3><code>&lt;property&gt;</code></h3>
    <p>Sets a property.</p>

    <h3><code>&lt;try-catch&gt;</code></h3>
    <p>Runs a set of tasks, with a provided error and clean-up handler.</p>

    <h3><code>&lt;converter-def&gt;</code></h3>
    <p>Register a type converter.  These are used when configuring a task
    or data-type from attributes.</p>

    <h3><code>&lt;type-def&gt;</code></h3>
    <p>Register a task or data-type.</p>

    <h3><code>&lt;import&gt;</code></h3>
    <p>Register the contents of an antlib.</p>

</section>

<section name="Conditions">

    <p>The following conditions are available </p>

    <h3><code>&lt;and&gt;</code></h3>
    <p>Evaluates a set of nested conditions, and AND them together.  Evaluation is
    lazy.  An empty <code>&lt;and&gt;</code> condition evaluates to true.</p>

    <h3><code>&lt;available&gt;</code></h3>
    <p>Tests if a particular class or resource is available.</p>

    <h3><code>&lt;file-test&gt;</code></h3>
    <p>Tests a file against a set of <a href="vfs.html#File Selectors">file selectors</a>.</p>

    <h3><code>&lt;is-set&gt;</code></h3>
    <p>Tests whether a proeprty is set, and not set to 'false'.</p>

    <h3><code>&lt;or&gt;</code></h3>
    <p>Evaluates a set of nested conditions, and OR them together.  Evaluation is
    lazy.  An empty <code>&lt;or&gt;</code> evaluates to true.</p>

    <h3><code>&lt;os&gt;</code></h3>
    <p>Tests which operating system the build is running on.</p>

    <h3><code>&lt;not&gt;</code></h3>
    <p>Negates a nested condition.</p>

</section>

<section name="File Name Mappers">

    <p>The following file name mappers are available:</p>

    <h3><code>&lt;chain&gt;</code></h3>

    <p>Applies a set of nested file name mappers to file names.</p>

    <h3><code>&lt;flatten&gt;</code></h3>

    <p>Maps all file names to a single directory.</p>

    <h3><code>&lt;prefix&gt;</code></h3>

    <p>Adds a prefix to the front of each file name.</p>

    <h3><code>&lt;map-extension&gt;</code></h3>

    <p>Changes the extension of file names.</p>

</section>
</body>

</document>
