<project name="Web Services Article" default="build" basedir=".">



  <property name="build" value="build" />
  <property environment="myenv" />
  <property file="article.props" />


  <target name="init">
      <tstamp/>
     <available property="JWSDP_HOME" value="${myenv.JWSDP_HOME}"
      file="${myenv.JWSDP_HOME}/common/lib/jaxr-ri.jar" />

     <antcall target="check.jwsdp.home" />

     

  <path id="classpath">
    <fileset dir="${myenv.JWSDP_HOME}/common/lib">
      <include name="*.jar"/>
    </fileset>
  </path>

  </target>

  <target name="prepare" depends="init"
   description="Create build directories.">
    <mkdir dir="${build}" />
  </target>

  <target name="build" depends="prepare" 
     description="Compile Java files" >
      <javac srcdir="." destdir="${build}">
    	<include name="*.java" />
        <classpath refid="classpath"/>
      </javac>
  </target>
  
  <target name="clean" depends="prepare">
    <delete dir="${build}" />
  </target>

 <target name="publish" depends="build" description="JAXR example for article" >
  <echo message="build done successfully" />
     <java classname="ProviderController" fork="yes"> 
      <classpath refid="classpath" />
      <classpath path="${build}" />
	<arg value="${userName}" />
	<arg value="${password}" />
	<arg value="${queryURL}" />
	<arg value="${publishURL}" />
    </java>
 </target> 

 <target name="query" depends="build" description="JAXR example for article" >
  <echo message="build done successfully" />
     <java classname="ClientQuery" fork="yes"> 
      <classpath refid="classpath" />
      <classpath path="${build}" />
	<arg value="${queryURL}" />
    </java>
 </target> 

 

 <target name="check.deletekey" unless="DELETE_KEY">
    <echo>
      The DELETE_KEY is not passed. You need to pass the 
      Key of organization to be deleted as DELETE_KEY like
      "ant -dDELETE_KEY="key_of_org_to_delete  delete" 
    </echo>
    <fail message="DELETE_KEY property is not passed"/>
  </target>

 <target name="check.jwsdp.home" unless="JWSDP_HOME">
    <echo>
      The JWSDP_HOME environment variables not set correctly. Please
      set this environment variable  to the directory
      where Java(TM) Web Services Developer Pack 1.0 EA is
      installed and rerun ant 
           
    </echo>
    <fail message="JWSDP_HOME environment variable is not set correctly"/>
  </target>

 <target name="delete" depends="build" description="JAXR example for article" >
  <echo message="build done successfully" />
     <antcall target="check.deletekey" />
     <java classname="ProviderController" fork="yes"> 
      <classpath refid="classpath" />
      <classpath path="${build}" />
	<arg value="${userName}" />
	<arg value="${password}" />
	<arg value="${queryURL}" />
	<arg value="${publishURL}" />
	<arg value="${DELETE_KEY}" />
    </java>
 </target> 
 
 <target name="help">
     <echo message="Please set variables in article.props and set JWSDP_HOME environment variables then use  one of the following " />
     <echo message="ant publish" />
     <echo message="ant  -DDELETE_KEY=Key_of_org_todelete delete" />
     <echo message="ant query" />
  </target>


</project>
