<?xml version="1.0"?>

<project name="Beehive/NetUI/JUnitTests" default="build" basedir=".">

    <import file="../../ant/netui-test-imports.xml"/>
    <import file="../../../../ant/beehive-tools.xml"/>

    <property name="module.name" value="junitTests"/>
    <property name="module.dir" location="${test.src.dir}/${module.name}"/>
    <property name="module.classes.dir" location="${test.classes.dir}/${module.name}"/>
    <property name="module.jar" location="${test.lib.dir}/beehive-netui-junitTests.jar"/>

    <path id="junit.classpath">
        <path refid="webapp.dependency.path"/>
        <path refid="junit.dependency.path"/>
        <path refid="strutstestcase.dependency.path"/>
        <path refid="servlet.dependency.path"/>
    </path>

    <target name="build">
        <echo>compile module: ${module.name}</echo>
        <echo>output directory: ${test.lib.dir}</echo>
        <echo>debug: ${compile.debug}</echo>

        <mkdir dir="${module.classes.dir}"/>

        <copy todir="${module.classes.dir}">
          <fileset dir="${module.dir}">
              <exclude name="./build.xml"/>
              <exclude name="**/*.java"/>
          </fileset>
        </copy>

        <copy todir="${module.classes.dir}/WEB-INF/" file="${netuiconfig.xml}"/>
        <copy todir="${module.classes.dir}/WEB-INF/" file="${default.web.xml}"/>
        <copy todir="${module.classes.dir}/WEB-INF/" file="${beehive-netui-validator-rules.xml}"/>
        <copy todir="${module.classes.dir}/WEB-INF/" file="${validator-rules.xml}"/>

        <!-- Build all page flows and other classes. -->
        <build-pageflows
               srcdir="${module.dir}"
               destdir="${module.classes.dir}"
               classpathref="junit.classpath"/>

        <!-- Generated struts-config and validator files are built into the classes dir.  In a
             webapp, this is WEB-INF/classes (where the runtime expects the files to be), but here
             it is simply the build dir.  We have to copy the files into the right place -
             this is an artifact of using MockStrutsTestCase against a nonstandard webapp build
             structure. -->
        <mkdir dir="${module.classes.dir}/WEB-INF/classes"/>
        <copy todir="${module.classes.dir}/WEB-INF/classes/_pageflow">
            <fileset dir="${module.classes.dir}/_pageflow">
                <include name="**"/>
            </fileset>
        </copy>

        <jar jarfile="${module.jar}" basedir="${module.classes.dir}">
            <manifest>
                <attribute name="Extension-Name" value="Beehive NetUI JUnit Tests"/>
                <attribute name="Specification-Title" value="Beehive NetUI JUnit Tests"/>
                <attribute name="Specification-Vendor" value="Apache Software Foundation"/>
                <attribute name="Specification-Version" value="${beehive.version}"/>
                <attribute name="Implementation-Title" value="Beehive NetUI JUnit Tests"/>
                <attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
                <attribute name="Implementation-Version" value="${beehive.version}"/>
                <attribute name="Beehive-Version" value="${beehive.version}"/>
            </manifest>
        </jar>
    </target>

    <target name="clean">
        <delete dir="${module.classes.dir}"/>
        <delete file="${module.jar}"/>
    </target>

</project>

