<?xml version="1.0"?>
<!--
 * Copyright 2002-2004  The Apache Software Foundation
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.

-->
<project default="all" name="JM">
    <import file="js.xml"/>
    <import file="xs.xml"/>

    <property name="build.jm" location="${build}/jm"/>
    <property name="build.jm.classes" location="${build.jm}/classes"/>
    <property name="build.jm.reports" location="${build.jm}/reports"/>
    <property name="build.jm.src" location="${build.jm}/src"/>
    <property name="build.jm.test" location="${build.jm}/test"/>
    <property name="build.jm.test.jaxme" location="${build.jm.test}/jaxme"/>
    <property name="build.jm.test.jaxme.src" location="${build.jm.test.jaxme}/src"/>
    <property name="src.jm" location="src/jaxme"/>

    <path id="jaxme.class.path">
      <pathelement location="${preqs}/junit.jar"/>
      <pathelement location="${dist}/jaxmeapi-${version}.jar"/>
      <pathelement location="${dist}/jaxmejs-${version}.jar"/>
      <pathelement location="${dist}/jaxmexs-${version}.jar"/>
      <pathelement location="${preqs}/ant.jar"/>
      <pathelement location="${preqs}/xml-apis-1.3.02.jar"/>
      <pathelement location="${preqs}/beaver.jar"/>
      <pathelement location="${preqs}/antlr.jar"/>
    </path>

    <path id="jaxme.test.path">
      <path refid="jaxme.class.path"/>
      <pathelement location="${dist}/jaxme2-${version}.jar"/>
    </path>

    <target name="clean">
        <delete dir="${build.jm}"/>
    </target>

    <target name="dirs" depends="JS.dirs">
        <mkdir dir="${build.jm.src}"/>
        <mkdir dir="${build.jm.classes}"/>
        <mkdir dir="${build.jm.reports}"/>
        <mkdir dir="${build.jm.test.jaxme.src}"/>
        <mkdir dir="${dist}"/>
    </target>

    <target name="JM.precompile" depends="dirs,JS.all,XS.all,JS.taskdef">
        <chainGenerator destDir="${build.jm.src}">
            <classpath>
                <pathelement location="${src.jm}"/>
            </classpath>   
            <chain
                controllerInterfaceName="org.apache.ws.jaxme.generator.sg.AttributeSG"
                chainInterfaceName="org.apache.ws.jaxme.generator.sg.AttributeSGChain"
                proxyClassName="org.apache.ws.jaxme.generator.sg.impl.AttributeSGChainImpl"
                implementationClassName="org.apache.ws.jaxme.generator.sg.impl.AttributeSGImpl"/>
            <chain
                controllerInterfaceName="org.apache.ws.jaxme.generator.sg.ComplexContentSG"
                chainInterfaceName="org.apache.ws.jaxme.generator.sg.ComplexContentSGChain"
                proxyClassName="org.apache.ws.jaxme.generator.sg.impl.ComplexContentSGChainImpl"
                implementationClassName="org.apache.ws.jaxme.generator.sg.impl.ComplexContentSGImpl"/>
            <chain
                controllerInterfaceName="org.apache.ws.jaxme.generator.sg.ComplexTypeSG"
                chainInterfaceName="org.apache.ws.jaxme.generator.sg.ComplexTypeSGChain"
                proxyClassName="org.apache.ws.jaxme.generator.sg.impl.ComplexTypeSGChainImpl"
                implementationClassName="org.apache.ws.jaxme.generator.sg.impl.ComplexTypeSGImpl"/>
            <chain
                controllerInterfaceName="org.apache.ws.jaxme.generator.sg.GroupSG"
                chainInterfaceName="org.apache.ws.jaxme.generator.sg.GroupSGChain"
                proxyClassName="org.apache.ws.jaxme.generator.sg.impl.GroupSGChainImpl"
                implementationClassName="org.apache.ws.jaxme.generator.sg.impl.GroupSGImpl"/>
            <chain
                controllerInterfaceName="org.apache.ws.jaxme.generator.sg.ObjectSG"
                chainInterfaceName="org.apache.ws.jaxme.generator.sg.ObjectSGChain"
                proxyClassName="org.apache.ws.jaxme.generator.sg.impl.ObjectSGChainImpl"
                implementationClassName="org.apache.ws.jaxme.generator.sg.impl.ObjectSGImpl"/>
            <chain
                controllerInterfaceName="org.apache.ws.jaxme.generator.sg.ParticleSG"
                chainInterfaceName="org.apache.ws.jaxme.generator.sg.ParticleSGChain"
                proxyClassName="org.apache.ws.jaxme.generator.sg.impl.ParticleSGChainImpl"
                implementationClassName="org.apache.ws.jaxme.generator.sg.impl.ParticleSGImpl"/>
            <chain
                controllerInterfaceName="org.apache.ws.jaxme.generator.sg.PropertySG"
                chainInterfaceName="org.apache.ws.jaxme.generator.sg.PropertySGChain"
                proxyClassName="org.apache.ws.jaxme.generator.sg.impl.PropertySGChainImpl"
                implementationClassName="org.apache.ws.jaxme.generator.sg.impl.PropertySGImpl"/>
            <chain
                controllerInterfaceName="org.apache.ws.jaxme.generator.sg.SchemaSG"
                chainInterfaceName="org.apache.ws.jaxme.generator.sg.SchemaSGChain"
                proxyClassName="org.apache.ws.jaxme.generator.sg.impl.SchemaSGChainImpl"
                implementationClassName="org.apache.ws.jaxme.generator.sg.impl.SchemaSGImpl"/>
            <chain
                controllerInterfaceName="org.apache.ws.jaxme.generator.sg.SGFactory"
                chainInterfaceName="org.apache.ws.jaxme.generator.sg.SGFactoryChain"
                proxyClassName="org.apache.ws.jaxme.generator.sg.impl.SGFactoryChainImpl"
                implementationClassName="org.apache.ws.jaxme.generator.sg.impl.SGFactoryImpl"/>
            <chain
                controllerInterfaceName="org.apache.ws.jaxme.generator.sg.SimpleContentSG"
                chainInterfaceName="org.apache.ws.jaxme.generator.sg.SimpleContentSGChain"
                proxyClassName="org.apache.ws.jaxme.generator.sg.impl.SimpleContentSGChainImpl"
                implementationClassName="org.apache.ws.jaxme.generator.sg.impl.SimpleContentSGImpl"/>
            <chain
                controllerInterfaceName="org.apache.ws.jaxme.generator.sg.SimpleTypeSG"
                chainInterfaceName="org.apache.ws.jaxme.generator.sg.SimpleTypeSGChain"
                proxyClassName="org.apache.ws.jaxme.generator.sg.impl.SimpleTypeSGChainImpl"
                implementationClassName="org.apache.ws.jaxme.generator.sg.impl.SimpleTypeSGImpl"/>
            <chain
                controllerInterfaceName="org.apache.ws.jaxme.generator.sg.TypeSG"
                chainInterfaceName="org.apache.ws.jaxme.generator.sg.TypeSGChain"
                proxyClassName="org.apache.ws.jaxme.generator.sg.impl.TypeSGChainImpl"
                implementationClassName="org.apache.ws.jaxme.generator.sg.impl.TypeSGImpl"/>
        </chainGenerator>
    </target>

    <target name="JM.compile" depends="dirs,JM.precompile">
        <javac classpathref="jaxme.class.path" debug="${debug}"
            optimize="${optimize}" destdir="${build.jm.classes}"
             source="1.3" target="1.3"
            failonerror="true">
            <src>
                <pathelement location="${src.jm}"/>
                <pathelement location="${build.jm.src}"/>   
            </src>
            <exclude name="org/apache/ws/jaxme/impl/CharSetXMLWriter.java" unless="have14"/>
            <exclude name="org/apache/ws/jaxme/junit/*Test.java"/>
            <exclude name="org/apache/ws/jaxme/examples/misc/address/*.java"/>
        </javac>
        <jar destfile="${dist}/jaxme2-rt-${version}.jar">
            <fileset dir="${build.jm.classes}">
                <exclude name="org/apache/ws/jaxme/generator/**/*"/>
                <exclude name="org/apache/ws/jaxme/examples/**/*"/>
                <exclude name="org/apache/ws/jaxme/junit/**/*"/>
            </fileset>
        </jar>
        <jar destfile="${dist}/jaxme2-${version}.jar">
            <fileset dir="${build.jm.classes}">
                <exclude name="org/apache/ws/jaxme/examples/**/*"/>
                <exclude name="org/apache/ws/jaxme/junit/**/*"/>
            </fileset>
        </jar>
        <zip destfile="${dist}/jaxme2-src-${version}.zip">
            <fileset dir="${src.jm}"/>
            <fileset dir="${build.jm.src}"/>
        </zip>
    </target>

    <target name="all" depends="JM.compile"/>

    <target name="JM.generate.jaxb" if="jaxb.home">
        <ant dir="src/test/jaxb" inheritall="false" inheritrefs="false">
            <property name="build" location="${build.jm}"/>
            <property name="dist" location="${dist}"/>
            <property name="preqs" location="${preqs}"/>
            <property name="run.jaxb" value="true"/>
            <property name="jaxb.home" location="${jaxb.home}"/>
        </ant>
    </target>

    <target name="JM.generate.jaxme" depends="JM.compile">
        <ant dir="src/test/jaxb" inheritall="false" inheritrefs="false">
            <property name="build" location="${build.jm}"/>
            <property name="dist" location="${dist}"/>
            <property name="preqs" location="${preqs}"/>
            <property name="run.jaxme" value="true"/>
            <property name="testsrc" location="src/test"/>
        	<property name="version" value="${version}"/>
        </ant>
    </target>

    <target name="JM.generate" depends="JM.generate.jaxme"/>

    <target name="JM.localtest" depends="JM.generate">
        <javac debug="${debug}"
            optimize="${optimize}" destdir="${build.jm.classes}"
            source="1.3" target="1.3"
            failonerror="true">
            <src>
                <pathelement location="${src.jm}"/>
                <pathelement location="${build.jm.src}"/>
            </src>
            <classpath>
                <pathelement location="${build.jm}/test/jaxme/classes"/>
                <path refid="jaxme.class.path"/>
            </classpath>
            <include name="org/apache/ws/jaxme/junit/*Test.java"/>
        </javac>
        <path id="jaxme.junit.path">
            <path refid="jaxme.test.path"/>
            <pathelement location="${build.jm.classes}"/>
            <pathelement location="${build.jm}/test/jaxme/classes"/>
            <pathelement location="${build.jm}/test/jaxme/src"/>
            <pathelement location="${build.jm}/examples/src"/>
        </path>
        <runtests reportsdir="${build.jm.reports}" classpathref="jaxme.junit.path">
            <tests>
                <fileset dir="${src.jm}"
                    includes="org/apache/ws/jaxme/junit/**/*Test.java"/>
            </tests>
        </runtests>
    </target>
   
    <target name="test" depends="JS.test,XS.test,JM.localtest"/>
</project>
