<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (c) 1997, 2019 Oracle and/or its affiliates. All rights reserved.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Distribution License v. 1.0, which is available at
    http://www.eclipse.org/org/documents/edl-v10.php.

    SPDX-License-Identifier: BSD-3-Clause

-->

<project basedir="." default="runclient" name="wsimport_catalog">
    <property environment="env"/>

    <property name="lib.home" value="${env.METRO_HOME}/lib"/>
    <property name="build.home" value="${basedir}/build"/>
    <property name="build.classes.home" value="${build.home}"/>

    <path id="metro.classpath">
        <pathelement location="${java.home}/../lib/tools.jar"/>
        <fileset dir="${lib.home}" includes="*.jar"/>
    </path>

    <taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
        <classpath refid="metro.classpath"/>
    </taskdef>

    <target name="server"/>

    <target name="runclient" depends="client">
        <antcall target="run"/>
    </target>

    <target name="client" depends="setup,generate-artifacts">
        <javac srcdir="${basedir}"
               fork="true"
               destdir="${build.classes.home}"
               debug="true"
               includes="**">
            <classpath refid="metro.classpath"/>
        </javac>
    </target>
    <target name="run">
        <java fork="true" classname="wsimport_catalog.WsimportCatalogTester">
            <classpath>
                <path refid="metro.classpath"/>
                <pathelement location="${build.classes.home}"/>
                <pathelement location="${basedir}/etc"/>
            </classpath>
        </java>
    </target>

    <target name="setup">
        <mkdir dir="${build.home}"/>
        <mkdir dir="${build.classes.home}"/>
    </target>

    <target name="generate-artifacts">
        <wsimport
                debug="true"
                extension="true"
                keep="true"
                destdir="${build.home}/"
                verbose="false"
                catalog="wsdlcatalog.xml"
                package="wsimport_catalog"
                wsdl="http://foo.org/hello?wsdl">
            <xmlcatalog refid="wsimportcatalog"/>
        </wsimport>
    </target>

    <xmlcatalog id="wsimportcatalog">
        <entity publicid="http://helloservice.org/types/HelloTypes.xsd" location="${basedir}/HelloTypes.xsd"/>
    </xmlcatalog>

    <target name="clean">
        <delete dir="${build.home}" includeEmptyDirs="true"/>
    </target>
</project>
