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

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

  <!--  ===================================================================== -->
  <!--                 Build GData Blogger samples.                           -->
  <!--  ===================================================================== -->

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

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

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

  <target name="sample.blogger.build" depends="sample.blogger.dependencies">
    <mkdir dir="${sample.blogger.build.lib}"/>
    <mkdir dir="${sample.blogger.build.classes}"/>
    <javac srcdir="${sample.blogger.src.home}"
           destdir="${sample.blogger.build.classes}"
           debug="${javac.debug}" debuglevel="${javac.debuglevel}"
           deprecation="false"
           optimize="true">
        <classpath refid="sample.blogger.compile.classpath"/>
    </javac>
    <jar jarfile="${sample.blogger.jar}"
         basedir="${sample.blogger.build.classes}">
      <manifest>
        <attribute name="Main-Class" value="${sample.blogger.main}"/>
      </manifest>
    </jar>
  </target>

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

  <target name="sample.blogger.run" depends="sample.blogger.build">
    <java fork="true" classname="${sample.blogger.main}">
      <arg line="--username ${sample.credentials.username} --password ${sample.credentials.password}"/>
      <classpath>
        <path refid="sample.blogger.compile.classpath"/>
        <path location="${sample-util.jar}"/>
        <path location="${sample.blogger.jar}"/>
      </classpath>
    </java>
  </target>

</project>
