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

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

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

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

  <!-- samples build Properties -->
  <property name="sample.appsforyourdomain.basedir"
            value="${build}/sample/appsforyourdomain"/>
  <property name="sample.appsforyourdomain.src.home"
            value="${sample.appsforyourdomain.basedir}"/>
  <property name="sample.appsforyourdomain.build.classes"
            value="${sample.appsforyourdomain.basedir}/classes"/>
  <property name="sample.appsforyourdomain.build.lib"
            value="${sample.appsforyourdomain.basedir}/lib"/>
  <property name="sample.appsforyourdomain.jar"
            value="${sample.appsforyourdomain.build.lib}/AppsForYourDomainClient.jar"/>
  <property name="sample.appsforyourdomain.main"
            value="sample.appsforyourdomain.AppsForYourDomainClient"/>
  <property name="sample.appsforyourdomain.migration.main"
            value="sample.appsforyourdomain.migration.AppsForYourDomainMigrationClient"/>
  <property name="sample.appsforyourdomain.gmailsettings.AppsForYourDomainGmailFilterClient"
            value="sample.appsforyourdomain.gmailsettings.AppsForYourDomainGmailFilterClient"/>
  <property name="sample.appsforyourdomain.gmailsettings.GmailSettingsClient"
            value="sample.appsforyourdomain.gmailsettings.GmailSettingsClient"/>
  <property name="sample.appsforyourdomain.gmailsettings.gui.GmailSettingsClient"
            value="sample.appsforyourdomain.gmailsettings.gui.GmailSettingsClient"/>


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

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

  <target name="sample.appsforyourdomain.build"
      depends="sample.appsforyourdomain.dependencies,core.sample.core.util.build">
    <mkdir dir="${sample.appsforyourdomain.build.lib}"/>
    <mkdir dir="${sample.appsforyourdomain.build.classes}"/>

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

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

  <target name="sample.appsforyourdomain.clean">
    <delete dir="${sample.appsforyourdomain.build.classes}"/>
  </target>


  <!-- samples run -->
  <target name="sample.appsforyourdomain.run"
          depends="sample.appsforyourdomain.build"
          description="Runs the AppsForYourDomain sample">
    <java fork="true" classname="${sample.appsforyourdomain.main}">
      <arg line="--admin_email ${sample.appsforyourdomain.admin_email} --admin_password ${sample.appsforyourdomain.admin_password} --domain ${sample.appsforyourdomain.domain}"/>
      <classpath>
        <path refid="sample.appsforyourdomain.compile.classpath"/>
        <path location="${sample.appsforyourdomain.jar}"/>
      </classpath>
    </java>
  </target>

  <target name="sample.appsforyourdomain.migration.run"
          depends="sample.appsforyourdomain.build"
          description="Runs the AppsForYourDomain Migration sample">
    <java fork="true" classname="${sample.appsforyourdomain.migration.main}">
      <arg line="--username ${sample.appsforyourdomain.migration.username} --password ${sample.appsforyourdomain.migration.password} --domain ${sample.appsforyourdomain.migration.domain}"/>
      <classpath>
        <path refid="sample.appsforyourdomain.compile.classpath"/>
        <path location="${sample.appsforyourdomain.jar}"/>
      </classpath>
    </java>
  </target>

  <target name="sample.appsforyourdomain.gmailsettings.filter.run"
          depends="sample.appsforyourdomain.build"
          description="Runs the AppsForYourDomain Gmail filter sample">
    <java fork="true" classname="${sample.appsforyourdomain.gmailsettings.AppsForYourDomainGmailFilterClient}">
      <arg line="--username ${sample.appsforyourdomain.admin_email} --password ${sample.appsforyourdomain.admin_password} --domain ${sample.appsforyourdomain.domain} --destination_user ${sample.appsforyourdomain.user_email}"/>
      <classpath>
        <path refid="sample.appsforyourdomain.compile.classpath"/>
        <path location="${sample.appsforyourdomain.jar}"/>
      </classpath>
    </java>
  </target>

  <target name="sample.appsforyourdomain.gmailsettings.run"
          depends="sample.appsforyourdomain.build"
          description="Runs the AppsForYourDomain Gmail settings sample">
    <java fork="true" classname="${sample.appsforyourdomain.gmailsettings.GmailSettingsClient}">
      <arg line="--username ${sample.appsforyourdomain.admin_email} --password ${sample.appsforyourdomain.admin_password} --domain ${sample.appsforyourdomain.domain} --destination_user ${sample.appsforyourdomain.user_email} --setting pop"/>
      <classpath>
        <path refid="sample.appsforyourdomain.compile.classpath"/>
        <path location="${sample.appsforyourdomain.jar}"/>
      </classpath>
    </java>
  </target>

  <target name="sample.appsforyourdomain.gmailsettings.gui.run"
          depends="sample.appsforyourdomain.build"
          description="Runs the AppsForYourDomain Gmail filter GUI sample">
    <java fork="true" classname="${sample.appsforyourdomain.gmailsettings.gui.GmailSettingsClient}">
      <classpath>
        <path refid="sample.appsforyourdomain.compile.classpath"/>
        <path location="${sample.appsforyourdomain.jar}"/>
      </classpath>
    </java>
  </target>

</project>
