<project name="docs" default="build.docs" basedir=".">

  <!-- Path containing docs.xml -->
  <dirname property="build_dir" file="${ant.file.docs}"/>
  <import file="${build_dir}/core.xml"/>
  <import file="${build_dir}/spreadsheet.xml"/>

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

  <!--  ===================================================================== -->
  <!--                 Build the GData Docs samples.                          -->
  <!--  ===================================================================== -->

  <!-- samples build Properties -->
  <property name="sample.docs.basedir"
            value="${basedir}/sample/docs"/>
  <property name="sample.docs.src.home"
            value="${sample.docs.basedir}"/>
  <property name="sample.docs.build.classes"
            value="${sample.docs.basedir}/classes"/>
  <property name="sample.docs.build.lib"
            value="${sample.docs.basedir}/lib"/>
  <property name="sample.docs.jar"
            value="${sample.docs.build.lib}/DocumentListDemo.jar"/>
  <property name="sample.docs.main"
            value="sample.docs.DocumentListDemo"/>

  <!-- dependency check -->
  <target name="sample.docs.dependencies">
    <antcall target="template.require.service.jar">
      <param name="template.service.name" value="docs"/>
      <param name="template.service.version" value="${docs.spec.version}"/>
    </antcall>
  </target>

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


  <!-- samples build -->
  <target name="sample.docs.build" depends="sample.docs.dependencies"
          description="Create binary distribution">

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

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

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

  </target>

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


  <!-- samples run -->
  <target name="sample.docs.run"
          depends="sample.docs.build"
          description="Runs the docs sample">
    <java fork="true" classname="${sample.docs.main}">
      <arg line="-u ${sample.credentials.username} -p ${sample.credentials.password}"/>
      <classpath>
        <path refid="sample.docs.compile.classpath"/>
        <path location="${sample.docs.jar}"/>
      </classpath>
    </java>
  </target>


</project>
