<?xml version="1.0" encoding="UTF-8"?>

<!-- $Revision: 1.21 $ $Date: 2004-10-27 20:54:09 +0600 (Wed, 27 Oct 2004) $ -->

<project default="jar"
    xmlns:j="jelly:core"
    xmlns:u="jelly:util"
    xmlns:maven="jelly:maven"
    xmlns:deploy="deploy"
    xmlns:ant="jelly:ant">

    <postGoal name="java:compile">
        <property name="metricsTmpDir" value="target/tmp/metrics"/>
        <ant:mkdir dir="${metricsTmpDir}"/>
        <ant:mkdir dir="${metricsTmpDir}/META-INF"/>
        <ant:copy toDir="${metricsTmpDir}">
            <ant:fileset dir="target/classes">
                <ant:include name="org/apache/synapse/metrics/**/*.class"/>
            </ant:fileset>
        </ant:copy>
        <copy file="conf/metrics_module.xml"
              tofile="${metricsTmpDir}/META-INF/module.xml"/>

        <jar jarfile="target/Metrics-${pom.currentVersion}.mar">
            <fileset dir="${metricsTmpDir}">
                 <include name="**"/>
            </fileset>
        </jar>

    </postGoal>
    <postGoal name="test:compile">
        
        <!--Creating the libs dir-->
        <deploy:copy-deps todir="target/lib"/>
        <attainGoal name="synapse_core"/>
    </postGoal>
    <goal name="synapse_core">
        <j:set var="class_test.dir" value="target/test-classes"/>

        <echo message="----------------Creating synapse.mar----------------"/>
        <mkdir dir="target/modules/synapse/META-INF"/>
        <copy file="conf/module.xml"
              tofile="target/modules/synapse/META-INF/module.xml"/>
        <jar jarfile="target/synapse-${pom.currentVersion}.mar">
            <fileset dir="target/modules/synapse">
                 <include name="**"/>
            </fileset>
            <fileset dir="target/classes">
                <include name="**"/>
            </fileset>

        </jar>


        <echo message="-----------Creating Server Repository ----------"/>
        <mkdir dir="target/synapse-repository/modules"/>
        <copy file="target/synapse-${pom.currentVersion}.mar"
              tofile="target/synapse-repository/modules/synapse-${pom.currentVersion}.mar"/>
        

        <copy file="target/lib/addressing-${addressing.version}.mar"
              tofile="target/synapse-repository/modules/addressing-${addressing.version}.mar"/>
        <copy file="target/lib/sandesha2-${sandesha2.version}.mar"
              tofile="target/synapse-repository/modules/sandesha2-${sandesha2.version}.mar"/>
        <copy file="target/lib/rampart-${rampart.version}.mar"
              tofile="target/synapse-repository/modules/rampart-${rampart.version}.mar"/>
        
        <copy todir="target/synapse-repository/conf">        
        	<fileset dir="../../repository/conf">
            <include name="**"/>
        	</fileset>
        </copy>


        <echo message="-----------Creating Testing Repository [testing_repository]  ----------"/>
        <mkdir dir="target/testing_repository/modules"/>

        <copy file="target/synapse-${pom.currentVersion}.mar"
              tofile="target/testing_repository/modules/synapse-${pom.currentVersion}.mar"/>
        <copy file="target/lib/addressing-${addressing.version}.mar"
              tofile="target/testing_repository/modules/addressing-${addressing.version}.mar"/>
        <copy file="target/lib/sandesha2-${sandesha2.version}.mar"
              tofile="target/testing_repository/modules/sandesha2-${sandesha2.version}.mar"/>
        <copy file="target/lib/rampart-${rampart.version}.mar"
              tofile="target/testing_repository/modules/rampart-${rampart.version}.mar"/>
        
        <copy file="../../repository/conf/axis2.xml"
              tofile="target/testing_repository/conf/axis2.xml"/>
        <copy file="test/rules/synapse_test.xml"
              tofile="target/testing_repository/conf/synapse.xml"/>

        <ant:delete dir="target/modules"/>
        <ant:delete dir="target/services"/>

        <ant:path id="classes_test.dir" location="${class_test.dir}"/>
        <maven:addPath id="maven.dependency.classpath" refid="classes_test.dir"/>
    </goal>

</project>
