<!--
  Build File for NVO Plugin
-->

<project name="nvo" default="jar" basedir=".">

  <!-- set global properties for this build -->
  <property name="jarname" value="nvoclient.jar"/>
  <property name="src" value="./src"/>
  <property name="wsdl" value="./wsdl"/>
  <property name="generated.dir" value="./generated"/>
  <property name="classes" value="./classes"/>
  <property name="lib"  value="./lib"/>
  <!-- the name of the jar file for the generated proxy classes -->
  <property name="generated.jar"
  value="${lib}/nvoproxy-generated.jar"/>
  <!-- the path to axis -->
  <property name="axis.home" value="../spex/lib/axis-1_2beta"/>
  <path id="axis.classpath">
    <fileset dir="${axis.home}/lib">
      <include name="**/*.jar" />
    </fileset>
  </path>
  <!-- set the compile.classpath property -->
  <path id="compile.classpath">
     <path refid="axis.classpath"/>
     <pathelement location="${classes}"/>
     <pathelement location="${generated.jar}"/>
  </path>

  <target name="init">
    <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create the classes directory structure used by compile -->
    <mkdir dir="${classes}"/>
    <!-- Create the library folder used to run the applet -->
    <mkdir dir="${lib}"/>
    <!-- Create the directory for axis2wsdl generated source code -->
    <mkdir dir="${wsdl}"/>
    <mkdir dir="${generated.dir}"/>
    <mkdir dir="${generated.dir}/src"/>
    <mkdir dir="${generated.dir}/classes"/>
  </target>

  <!-- test for the jar file for the nvo proxy classes -->
  <condition property="nvo_proxy.notAvailable">
    <not>
      <available file="${generated.jar}"/>
    </not>
  </condition>

  <!-- National Virtual Observatory Web Services Client 

       Download various WSDL files, use wsdl2java to generate
       proxy classes, compile them, and create a jar file.

       This proxy classes allow the java client to interact with 
       web services via the generated classes.
    -->
  <target name="nvo_proxy"
          depends="init"
	  description="Build the proxy library"
	  if="nvo_proxy.notAvailable"
	  >
    <taskdef resource="axis-tasks.properties" classpathref="axis.classpath" />

    <echo>Downloading wsdl files...</echo>
    <get usetimestamp="true" verbose="on"
	 src="http://voservices.net/NED/ws_v1_0/NED.asmx?WSDL" dest="${wsdl}/ned.wsdl"/>
    <get usetimestamp="true" verbose="on"
	 src="http://voservices.net/spectrum/ws_v2_0/search.asmx?wsdl" dest="${wsdl}/spectrum.wsdl"/>
    <get usetimestamp="true" verbose="on"
	 src="http://skyservice.pha.jhu.edu/SdssCutout/SdssCutout.asmx?WSDL" dest="${wsdl}/sdsscutout.wsdl"/>
    <get usetimestamp="true" verbose="on"
	 src="http://openskyquery.net/Sky/SkyPortal/SkyPortal.asmx?WSDL" dest="${wsdl}/skyportal.wsdl"/>
    <get usetimestamp="true" verbose="on"
	 src="http://cdsws.u-strasbg.fr/axis/services/VizieR?wsdl" dest="${wsdl}/vizier.wsdl"/>

    <!-- Generate java classes for NED Service -->
    <axis-wsdl2java
      output="${generated.dir}/src"
      testcase="false"
      verbose="false"
      url="./${wsdl}/ned.wsdl" 
    >
    <mapping
       namespace="http://axis.apache.org/ns/interop"
       package="interop" />
    </axis-wsdl2java>

    <!-- generate java classes for Spectrum Service -->
    <axis-wsdl2java
      output="${generated.dir}/src"
      testcase="false"
      verbose="false"
      url="./${wsdl}/spectrum.wsdl" 
    >
    <mapping
       namespace="http://axis.apache.org/ns/interop"
       package="interop" />
    </axis-wsdl2java>

    <!-- generate java classes for Image Cutout Service -->
    <axis-wsdl2java
      output="${generated.dir}/src"
      testcase="false"
      verbose="false"
      url="./${wsdl}/sdsscutout.wsdl"
    >
    <mapping
       namespace="http://axis.apache.org/ns/interop"
       package="interop" />
    </axis-wsdl2java>

    <!-- generate java objects for SkyPortal Service -->
    <axis-wsdl2java
      output="${generated.dir}/src"
      testcase="false"
      verbose="false"
      url="./${wsdl}/skyportal.wsdl"
    >
    <mapping
       namespace="http://axis.apache.org/ns/interop"
       package="interop" />
    </axis-wsdl2java>

    <!-- generate java objects for VizieR Service -->
    <axis-wsdl2java
        output="${generated.dir}/src"
        testcase="false"
        verbose="false"
        url="./${wsdl}/vizier.wsdl"
    >
    <mapping
       namespace="http://axis.apache.org/ns/interop"
       package="interop" />
    </axis-wsdl2java>

    <javac 
          srcdir="${generated.dir}/src" 
	  destdir="${generated.dir}/classes" 
	  debug="off">
       <classpath refid="axis.classpath"/>
    </javac>

    <!-- Put everything in ${classes} into the ${jarname} file -->
    <jar jarfile="${generated.jar}" basedir="${generated.dir}/classes"/>

  </target>

  <!-- compile the GUI Client which uses the WSDL code -->
  <target name="nvo_plugin" depends="nvo_proxy">
    <javac 
          srcdir="${src}" 
	  destdir="${classes}" 
	  debug="on">
       <classpath refid="compile.classpath"/>
    </javac>
  </target>

  <target name="jar" depends="nvo_plugin">
    <!-- Put everything in ${classes} into the ${jarname} file -->
    <jar jarfile="${lib}/${jarname}" basedir="${classes}"/>
  </target>

  <!-- run the NVO Plugin Demo as an application from the command line -->
  <target name="run" depends="jar">
     <java classname="edu.bu.lite.nvo.Demo" fork="yes">
        <classpath refid="compile.classpath"/>
	<arg value="-debug"/>
	<jvmarg	value="-Dcom.apple.mrj.application.apple.menu.about.name=NVO Plugin Demo"/>
     </java>
  </target>

  <!-- this cleans up after this project, which will also clean related projects -->
  <target name="clean">
     <!-- clean up this project -->
     <delete>
        <fileset dir="${classes}" includes="**/*.class"/>
     </delete>
     <delete file="${lib}/${jarname}"/>
  </target>
</project>



