<project name="webmastertools" default="sample.webmastertools.build" basedir=".">
  <!-- Path containing core.xml -->
  <dirname property="build_dir" file="${ant.file.webmastertools}"/>
  <import file="${build_dir}/core.xml"/>

  <!--  ===================================================================== -->
  <!--                 Build GData webmastertools library.                            -->
  <!--  ===================================================================== -->

  <property name="gdata-webmastertools.jar"
    value="${build.jars}/gdata-webmastertools-${webmastertools.spec.version}.jar"/>

  <property name="sample.webmastertools.basedir"           value="${build}/sample/webmastertools"/>
  <property name="sample.webmastertools.src.home"          value="${sample.webmastertools.basedir}"/>
  <property name="sample.webmastertools.build.classes"     value="${sample.webmastertools.basedir}/classes"/>
  <property name="sample.webmastertools.build.lib"         value="${sample.webmastertools.basedir}/lib"/>
  <property name="sample.webmastertools.jar"               value="${sample.webmastertools.build.lib}/WebmasterToolsClient.jar"/>
  <property name="sample.webmastertools.main"              value="sample.webmastertools.WebmasterToolsClient"/>

  <target name="sample.webmastertools.clean"
   description="Delete old build and dist directories">
    <delete dir="${sample.webmastertools.build.classes}"/>
  </target>

  <target name="sample.webmastertools.dependencies">
    <antcall target="template.require.service.jar">
      <param name="template.service.name" value="webmastertools"/>
      <param name="template.service.version" value="${webmastertools.spec.version}"/>
    </antcall>
  </target>

  <path id="sample.webmastertools.compile.classpath">
    <path refid="build.service.core.classpath"/>
    <pathelement location="${gdata-webmastertools.jar}"/>
    <pathelement location="${sample-util.jar}"/>
  </path>

  <!-- samples build -->
  <target name="sample.webmastertools.build"
      depends="sample.webmastertools.dependencies,core.sample.core.util.build"
      description="Create binary distribution">

    <mkdir   dir="${sample.webmastertools.build.lib}"/>
    <mkdir    dir="${sample.webmastertools.build.classes}"/>

    <javac srcdir="${sample.webmastertools.src.home}"
           destdir="${sample.webmastertools.build.classes}"
           debug="${javac.debug}" debuglevel="${javac.debuglevel}"
           deprecation="false"
           optimize="true">
        <classpath refid="sample.webmastertools.compile.classpath"/>
    </javac>

    <jar jarfile="${sample.webmastertools.jar}"
         basedir="${sample.webmastertools.build.classes}">
      <manifest>
        <attribute name="Main-Class" value="${sample.webmastertools.main}"/>
      </manifest>
    </jar>
  </target>

  <!-- samples run -->
  <target name="sample.webmastertools.run"
          depends="sample.webmastertools.build"
          description="Runs the webmastertools sample">

    <java fork="true" classname="${sample.webmastertools.main}">
      <arg line="--username=${sample.credentials.username} --password=${sample.credentials.password}"/>
      <classpath>
        <path refid="sample.webmastertools.compile.classpath"/>
        <path location="${sample.webmastertools.jar}"/>
      </classpath>
    </java>

  </target>
</project>
