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


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

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

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

  <!-- samples build Properties -->
  <property name="sample.photos.basedir"
            value="${basedir}/sample/photos"/>
  <property name="sample.photos.src.home"
            value="${sample.photos.basedir}"/>
  <property name="sample.photos.build.classes"
            value="${sample.photos.basedir}/classes"/>
  <property name="sample.photos.build.lib"
            value="${sample.photos.basedir}/lib"/>
  <property name="sample.photos.jar"
            value="${sample.photos.build.lib}/PhotosClient.jar"/>
  <property name="sample.photos.main"
            value="sample.photos.PicasawebCommandLine"/>
  <property name="sample.photospartial.main"
            value="sample.photos.PicasawebPartialDemo"/>

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

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

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

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

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

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

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

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

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

  </target>

  <target name="sample.photospartial.run"
          depends="sample.photos.build"
          description="Runs the Photos sample">

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

  </target>


</project>
