<?xml version="1.0" encoding="UTF-8"?>
<!--*************************************************************************
Filename        :   build.xml
Project         :   proj4js
Document Type   :   XML
Purpose         :   build file for ant tool

Author     Date            Description
M.Adair    17-Dec-2001     initial version copied from mapbuilder

$Id: build.xml 2955 2007-07-09 12:12:27Z steven $
***************************************************************************--><!--
-->
<!-- A "project" describes a set of targets that may be requested
     when Ant is executed.  The "default" attribute defines the
     target which is executed if no specific target is requested,
     and the "basedir" attribute defines the current working directory
     from which Ant executes the requested task.  This is normally
     set to the current working directory.
-->
  <project basedir=".." default="dist" name="proj4js">

<!-- ===================== Property Definitions =========================== -->
<!--
  Each of the following properties are used in the build script.
  Values for these properties are set by the first place they are
  defined, from the following list:

  * Definitions on the "ant" command line (ant -Dfoo=bar compile).

  * Definitions from a "build.properties" file in the top level
    source directory of this application.

  * Definitions from a "build.properties" file in the developer's
    home directory.

  * Default definitions in this build.xml file.

  You will note below that property values can be composed based on the
  contents of previously defined properties.  This is a powerful technique
  that helps you minimize the number of changes required when your development
  environment is modified.  Note that property composition is allowed within
  "build.properties" files as well as in the "build.xml" script.
-->
  <property file="build.properties"/>
  <property file="${user.home}/build.properties"/>
  <property file="default.properties"/>  	

<!-- ==================== File and Directory Names ======================== -->
<!--

  These properties generally define file and directory names (or paths) that
  affect where the build process stores its outputs.

  app.name             Base name of this application, used to
                       construct filenames and directories.
                       Defaults to "myapp".

  app.path             Context path to which this application should be
                       deployed (defaults to "/" plus the value of the
                       "app.name" property).

  app.version          Version number of this iteration of the application.

  build.home           The directory into which the "prepare" and
                       "compile" targets will generate their output.
                       Defaults to "build".

  dist.home            The name of the base directory in which
                       distribution files are created.
                       Defaults to "dist".
-->

  <property environment="env"/>
  <property name="app.name" value="proj4js"/>
  <property name="app.path" value="/${app.name}"/>
  <property name="app.version" value="1.0.0-RC1"/>
  <property name="build.home" value="${basedir}/tempBuild"/>
  <property name="dist.home" value="${basedir}/dist"/>
  <property name="docs.home" value="${build.home}/docs"/>


<!-- ==================== 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.

  Normally, this task is executed indirectly when needed.

-->

  <target name="prepare">
    <!-- Create build directories as needed -->
    <mkdir dir="${build.home}"/>
    <!-- Copy static content of the mapbuilder project  -->
    <copy todir="${build.home}">
      <fileset dir="${basedir}" excludes="tools/*.pyc "
          includes="index.html
                    lib/proj4js.js,
                    lib/proj4js-combined.js
                    lib/proj4js-compressed.js
                    lib/defs/**
                    lib/projCode/**
                    build/**
                    demo/**
                    test/**
                    tools/**"
      />
    </copy>
  </target>


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

  The "clean" target deletes any previous "build" and "dist" directory,
  so that you can be ensured the application can be built from scratch.

-->

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


<!-- ==================== Documentation =================================== -->

  <target description="Create documentation" name="docs" depends="prepare">
  
    <mkdir dir="${build.home}/docs"/>
    <mkdir dir="${build.home}/docs/NaturalDocs"/>
    
    <echo message="Generating documentation"/>
    <exec executable="cmd" os="Windows XP" dir="${build.home}">
        <arg line="/c perl C:\Progra~1\NaturalDocs\NaturalDocs -i ./lib -o html ./docs/NaturalDocs -p ./docs/NaturalDocs -r"/>
    </exec>
  </target>


<!-- ==================== Dist Target ===================================== -->
<!--
  The "dist" target creates the zip file distribution for the Apache/PHP
  environment.
-->
  <target name="dist" description="Create binary distribution" depends="clean,prepare,docs">

    <mkdir dir="${dist.home}"/>

    <!-- Create application zip file -->
    <zip destfile="${dist.home}/${app.name}-${app.version}.zip" update="true">
      <zipfileset dir="${build.home}" prefix="proj4js"/>
    </zip>

  </target>

</project>
