<?xml version="1.0"?>

<!--
    ============================================================================
    Plugin for Triactive JDO implementation.
    ============================================================================
-->
<project
    xmlns:j="jelly:core"
    xmlns:ant="jelly:ant"
    xmlns:u="jelly:util"
    xmlns:doc="doc">

    <!--
        ========================================================================
        Default goal.
        ========================================================================
    -->
    <goal name="tjdo"
        description="Enhance classes for use with Triactive JDO"
        prereqs="tjdo:enhance"/>

    <!--
        ========================================================================
        Initializations.
        ========================================================================
    -->
    <goal name="tjdo:init">
    </goal>

    <!--
        ========================================================================
        Run the enhancer on any class files to make the persistable.
        ========================================================================
    -->
    <goal name="tjdo:enhance"
        prereqs="tjdo:init">
        <echo>JDO-enhancing classes for Triactive JDO</echo>

        <!-- Construct FileSet of JDO files for enhancing -->
        <j:set var="jdo_fileset_dir_var_name" value="maven.tjdo.jdo.fileset.dir"/>
        <fileset dir="${context.getVariable(jdo_fileset_dir_var_name)}" id="jdo.files">
            <!-- Includes -->
            <j:set var="jdo_fileset_include_var_name" value="maven.tjdo.jdo.fileset.include"/>
            <j:if test="${context.getVariable(jdo_fileset_include_var_name) != null}">
                <include name="${context.getVariable(jdo_fileset_include_var_name)}"/>
            </j:if>

            <!-- Excludes -->
            <j:set var="jdo_fileset_exclude_var_name" value="maven.tjdo.jdo.fileset.exclude"/>
            <j:if test="${context.getVariable(jdo_fileset_exclude_var_name) != null}">
                <exclude name="${context.getVariable(jdo_fileset_exclude_var_name)}"/>
            </j:if>
        </fileset>
        <pathconvert pathsep=" " property="jdofiles" refid="jdo.files"/>

        <!-- Construct CLASSPATH to include TJDO and dependencies -->
        <path id="myclasspath">
            <path refid="maven.dependency.classpath"/>
            <pathelement path="${maven.build.dest}"/>
            <pathelement path="${plugin.getDependencyPath('tjdo')}"/>
        </path>

        <!-- Run enhancer on JDO files -->
        <ant:java dir="${maven.build.dest}"
            classname="com.triactive.jdo.enhance.SunReferenceEnhancer"
            failonerror="true"
            fork="true">
            <classpath refid="myclasspath"/>
            <arg line="${jdofiles}"/>
        </ant:java>

        <echo>Classes are now JDO-enhanced for Triactive JDO</echo>
    </goal>

</project>
