<?xml version="1.0"?>
<project name="spring-ws-airline-sample-spring-ws-client" default="build" xmlns:artifact="urn:maven-artifact-ant">
    <property name="bin.dir" value="bin"/>
    <property name="src.dir" value="src"/>
    <property name="gen.dir" value="gen"/>
    <property name="schema" value="../../src/main/webapp/messages.xsd"/>

    <target name="init">
        <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant">
            <classpath>
                <pathelement location="${basedir}/../../../maven-ant-tasks-2.0.7.jar"/>
            </classpath>
        </typedef>

        <artifact:remoteRepository id="main" url="http://repo1.maven.org/maven2/"/>
        <artifact:remoteRepository id="java.net" url="https://maven-repository.dev.java.net/nonav/repository"
                                   layout="legacy"/>

        <artifact:dependencies pathId="classpath">
            <remoteRepository refid="main"/>
            <remoteRepository refid="java.net"/>
            <dependency groupId="org.springframework.ws" artifactId="spring-ws-core" version="1.5.3"/>
            <dependency groupId="org.springframework.ws" artifactId="spring-ws-security" version="1.5.3"/>
            <dependency groupId="com.sun.xml.messaging.saaj" artifactId="saaj-impl" version="1.3"/>
            <dependency groupId="commons-httpclient" artifactId="commons-httpclient" version="3.0.1"/>
            <dependency groupId="xmlbeans" artifactId="xbean" version="2.2.0"/>
            <dependency groupId="log4j" artifactId="log4j" version="1.2.13"/>
        </artifact:dependencies>

    </target>

    <target name="generate" depends="init">
        <mkdir dir="${gen.dir}"/>
        <taskdef name="xmlbean" classname="org.apache.xmlbeans.impl.tool.XMLBean" classpathref="classpath"/>
        <xmlbean schema="${schema}" srcgendir="${gen.dir}" classgendir="${bin.dir}" classpathref="classpath"/>
    </target>

    <target name="build" depends="init,generate">
        <mkdir dir="${bin.dir}"/>
        <javac destdir="${bin.dir}">
            <src path="${src.dir}"/>
            <src path="${gen.dir}"/>
            <classpath refid="classpath"/>
        </javac>
        <copy todir="${bin.dir}">
            <fileset dir="${src.dir}">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>

    <target name="clean">
        <delete dir="${bin.dir}"/>
        <delete dir="${gen.dir}"/>
    </target>

    <target name="run" depends="getFlights, getFrequentFlyerMileage"/>

    <target name="getFlights" depends="build">
        <java classname="org.springframework.ws.samples.airline.client.sws.GetFlights" fork="true"
              failonerror="true">
            <classpath refid="classpath"/>
            <classpath location="${bin.dir}"/>
        </java>
    </target>

    <target name="getFrequentFlyerMileage" depends="build">
        <java classname="org.springframework.ws.samples.airline.client.sws.GetFrequentFlyerMileage" fork="true"
              failonerror="true">
            <classpath refid="classpath"/>
            <classpath location="${bin.dir}"/>
        </java>
    </target>

</project>
