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

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

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

  <!-- samples build Properties -->
  <property name="sample.calendar.basedir"           value="${build}/sample/calendar"/>
  <property name="sample.calendar.src.home"          value="${sample.calendar.basedir}"/>
  <property name="sample.calendar.build.classes"     value="${sample.calendar.basedir}/classes"/>
  <property name="sample.calendar.build.lib"         value="${sample.calendar.basedir}/lib"/>
  <property name="sample.calendar.eventfeed.jar"     value="${sample.calendar.build.lib}/EventFeedDemo.jar"/>
  <property name="sample.calendar.eventfeed.main"    value="sample.calendar.EventFeedDemo"/>
  <property name="sample.calendar.eventpartial.jar"  value="${sample.calendar.build.lib}/EventFeedPartialDemo.jar"/>
  <property name="sample.calendar.eventpartial.main" value="sample.calendar.EventFeedPartialDemo"/>
  <property name="sample.calendar.calendarfeed.jar"  value="${sample.calendar.build.lib}/CalendarFeedDemo.jar"/>
  <property name="sample.calendar.calendarfeed.main" value="sample.calendar.CalendarFeedDemo"/>
  <property name="sample.calendar.aclfeed.jar"       value="${sample.calendar.build.lib}/AclFeedDemo.jar"/>
  <property name="sample.calendar.aclfeed.main"      value="sample.calendar.AclFeedDemo"/>


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

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

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

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

    <!-- Compile Calendar samples -->
    <javac srcdir="${sample.calendar.src.home}"
           destdir="${sample.calendar.build.classes}"
           debug="${javac.debug}" debuglevel="${javac.debuglevel}"
           deprecation="false"
           optimize="true">
        <classpath refid="sample.calendar.compile.classpath"/>
    </javac>

    <!-- Create EventFeedDemo application JAR file -->
    <jar jarfile="${sample.calendar.eventfeed.jar}"
         basedir="${sample.calendar.build.classes}">
      <manifest>
        <attribute name="Main-Class" value="${sample.calendar.eventfeed.main}"/>
      </manifest>
    </jar>

    <!-- Create EventFeedDemo application JAR file -->
    <jar jarfile="${sample.calendar.eventpartial.jar}"
         basedir="${sample.calendar.build.classes}">
      <manifest>
        <attribute name="Main-Class" value="${sample.calendar.eventpartial.main}"/>
      </manifest>
    </jar>

    <!-- Create CalendarFeedDemo application JAR file -->
    <jar jarfile="${sample.calendar.calendarfeed.jar}"
         basedir="${sample.calendar.build.classes}">
      <manifest>
        <attribute name="Main-Class" value="${sample.calendar.calendarfeed.main}"/>
      </manifest>
    </jar>

    <!-- Create AclFeedDemo application JAR file -->
    <jar jarfile="${sample.calendar.aclfeed.jar}"
         basedir="${sample.calendar.build.classes}">
      <manifest>
        <attribute name="Main-Class" value="${sample.calendar.aclfeed.main}"/>
      </manifest>
    </jar>

  </target>


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


  <!-- samples run -->
  <target name="sample.calendar.eventfeed.run" depends="sample.calendar.build"
   description="Runs the Calendar event feed sample">
    <!-- Run EventFeedDemo -->
    <java fork="true" classname="${sample.calendar.eventfeed.main}">
      <arg line="${sample.credentials.username} ${sample.credentials.password}"/>
      <classpath>
        <path refid="sample.calendar.compile.classpath"/>
        <path location="${sample.calendar.eventfeed.jar}"/>
      </classpath>
    </java>
  </target>

  <target name="sample.calendar.eventpartial.run" depends="sample.calendar.build"
   description="Runs the Calendar event feed partial demo sample">
    <!-- Run EventFeedDemo -->
    <java fork="true" classname="${sample.calendar.eventpartial.main}">
      <arg line="${sample.credentials.username} ${sample.credentials.password}"/>
      <classpath>
        <path refid="sample.calendar.compile.classpath"/>
        <path location="${sample.calendar.eventpartial.jar}"/>
      </classpath>
    </java>
  </target>

  <target name="sample.calendar.calendarfeed.run" depends="sample.calendar.build"
   description="Runs the Calendar feed sample">
    <!-- Run CalendarFeedDemo -->
    <java fork="true" classname="${sample.calendar.calendarfeed.main}">
      <arg line="${sample.credentials.username} ${sample.credentials.password}"/>
      <classpath>
        <path refid="sample.calendar.compile.classpath"/>
        <path location="${sample.calendar.calendarfeed.jar}"/>
      </classpath>
    </java>
  </target>

  <target name="sample.calendar.aclfeed.run" depends="sample.calendar.build"
   description="Runs the Calendar ACL feed sample">
    <!-- Run AclFeedDemo -->
    <java fork="true" classname="${sample.calendar.aclfeed.main}">
      <arg line="${sample.credentials.username} ${sample.credentials.password}"/>
      <classpath>
        <path refid="sample.calendar.compile.classpath"/>
        <path location="${sample.calendar.aclfeed.jar}"/>
      </classpath>
    </java>
  </target>


  <target name="sample.calendar.run" depends="sample.calendar.build"
   description="Runs the Calendar samples">
    <antcall target="sample.calendar.eventfeed.run"/>
    <antcall target="sample.calendar.calendarfeed.run"/>
    <antcall target="sample.calendar.aclfeed.run"/>
  </target>


</project>
