
<!--  ==================================================================== -->
<!--                      AuthSub Sample Targets                            -->
<!--  ==================================================================== -->

<project name="authsub" default="sample.authsub.build" basedir=".">


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

<!-- ==================== AuthSub property names ========================= -->

  <property name="sample.authsub.app.name"      value="authsub_sample"/>
  <property name="sample.authsub.app.path"      value="/${sample.authsub.app.name}"/>
  <property name="sample.authsub.app.version"   value="1.0"/>
  <property name="sample.authsub.basedir"       value="${build}/sample/authsub"/>
  <property name="sample.authsub.build.home"    value="${sample.authsub.basedir}/build"/>
  <property name="sample.authsub.dist.home"     value="${sample.authsub.basedir}/dist"/>
  <property name="sample.authsub.src.home"      value="${sample.authsub.basedir}/src"/>
  <property name="sample.authsub.web.home"      value="${sample.authsub.basedir}/web"/>


<!-- ==================== AuthSub Clean Target ========================== -->


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



<!-- ==================== Compilation class path ========================= -->

  <path id="sample.authsub.compile.classpath">
    <!-- Include all JAR files that will be included in /WEB-INF/lib -->
    <path refid="build.service.core.classpath"/>
    <pathelement location="${servlet.jar}"/>
    <pathelement location="${gdata-calendar.jar}"/>
    <pathelement location="${gdata-codesearch.jar}"/>
    <pathelement location="${gdata-spreadsheet.jar}"/>
  </path>



<!-- ==================== Compile Target ================================ -->

<!--

  The "compile" target transforms source files (from your "src" directory)
  into object files in the appropriate location in the build directory.
  This example assumes that you will be including your classes in an
  unpacked directory hierarchy under "/WEB-INF/classes".

-->

  <target name="sample.authsub.compile" depends="sample.authsub.prepare,require.servlet-api"
   description="Compile Java sources">

    <!-- Compile Java classes as necessary -->
    <mkdir    dir="${sample.authsub.build.home}/WEB-INF/classes"/>
    <javac srcdir="${sample.authsub.src.home}"
           destdir="${sample.authsub.build.home}/WEB-INF/classes"
           debug="${javac.debug}" debuglevel="${javac.debuglevel}"
           deprecation="false"
           optimize="true">
        <classpath refid="sample.authsub.compile.classpath"/>
    </javac>

    <!-- Copy application resources -->
    <copy  todir="${sample.authsub.build.home}/WEB-INF/classes">
      <fileset dir="${sample.authsub.src.home}" excludes="**/*.java"/>
    </copy>

  </target>


<!-- ==================== AuthSub Build Target ============================ -->

  <target name="sample.authsub.build"
    depends="sample.authsub.compile,sample.core.dependencies"
    description="Create binary distribution">

    <!-- Copy dependency resources to create a single deploy jar -->
    <unjar src="${gdata-calendar.jar}"
           dest="${sample.authsub.build.home}/WEB-INF/classes"/>
    <unjar src="${gdata-core.jar}"
           dest="${sample.authsub.build.home}/WEB-INF/classes"/>
    <unjar src="${gdata-client-meta.jar}"
           dest="${sample.authsub.build.home}/WEB-INF/classes"/>
    <unjar src="${gdata-client.jar}"
           dest="${sample.authsub.build.home}/WEB-INF/classes"/>
    <unjar src="${google-collect.jar}"
           dest="${sample.authsub.build.home}/WEB-INF/classes"/>
    <unjar src="${google-jsr305.jar}"
           dest="${sample.authsub.build.home}/WEB-INF/classes"/>

    <!-- Create dist directory -->
    <mkdir   dir="${sample.authsub.dist.home}"/>

    <!-- Create application JAR file -->
    <jar jarfile="${sample.authsub.dist.home}/${sample.authsub.app.name}.war"
         basedir="${sample.authsub.build.home}"/>

  </target>


<!-- ==================== AuthSub Prepare Target ========================= -->

<!--

  The "prepare" target is used to create the "build" destination directory,
  and copy the static contents of your web application to it.  If you need
  to copy static files from external dependencies, you can customize the
  contents of this task.

-->

  <target name="sample.authsub.prepare">

    <!-- Create build directories as needed -->
    <mkdir  dir="${sample.authsub.build.home}"/>
    <mkdir  dir="${sample.authsub.build.home}/WEB-INF"/>
    <mkdir  dir="${sample.authsub.build.home}/WEB-INF/classes"/>


    <!-- Copy static content of this web application -->
    <copy todir="${sample.authsub.build.home}">
      <fileset dir="${sample.authsub.web.home}"/>
    </copy>

    <mkdir  dir="${sample.authsub.build.home}/WEB-INF/lib"/>

  </target>

</project>
