<!-- ===========================================================================

Installing the build tools
==========================

This build system is based on Jakarta Ant, which is a Java building tool
originally developed for the Jakarta Tomcat project but now used in many other
Apache projects and extended by many developers.

Ant is a little but very handy tool that uses a build file written in XML
(this file) as building instructions. For more information refer to
"http://jakarta.apache.org/ant/".

The only thing that you have to make sure of is that the "JAVA_HOME" environment
property is set to match the top level directory containing the JVM you want
to use. For example:

C:\> set JAVA_HOME=C:\jdk1.4

or on Unix:

% setenv JAVA_HOME /usr/local/java
  (csh)
> JAVA_HOME=/usr/java; export JAVA_HOME
  (ksh, bash)

That's it!

Building instructions
=====================

Ok, let's build the samples. First, make sure your current working directory is
where this very file is located. Then type:

  ./build.sh all (unix)
  .\build.bat all (win32)

To build the framework, examples, and tests or:

  ./build.sh (unix)
  .\build.bat (win32)
  
To list all the possible build targets.

If everything is right (see *) and all the required packages are visible, this action
will generate some jar files:

  templateproject.jar - This jar contains the templateproject sources.
  tests.jar           - This jar contains unit tests for the source classes.

in the ./build directory.

* On Win/98 you may get an "Out of Environment Space" error message. This happens if
Windows provides too small a space for environment variables. To work around this
limitation: 
  Close the DOS window (the error can corrupt its CLASSPATH variable). 
  Open a new DOS window. Click on the MS-DOS icon at the top left of the window. 
  Select the Properties option. 
  Click on the Memory tab. 
  Adjust the "Initial Environment" drop-down box from "Auto" to "2816". 
  Click OK. 
Then try building.

-->

<project name="TemplateProject" default="usage" basedir=".">

  <!-- =================================================================== -->
  <!-- Initialization target                                               -->
  <!-- =================================================================== -->
  <target name="init">
    <tstamp/>
    <property name="Name" value="Voting"/>
    <property name="name" value="voting"/>
    <property name="version" value="development"/>
    <property name="year" value="2003"/>

    <echo message="----------- ${Name} ${version} [${year}] ------------"/>

    <property name="build.compiler" value="modern"/>
    <property name="debug" value="off"/>
    <property name="optimize" value="on"/>
    <property name="deprecation" value="on"/>
    <property name="packages" value="edu.*"/>

    <!-- Define the source directories -->
    <property name="root.dir" value="./"/>
    <property name="doc.dir" value="${root.dir}/doc"/>
    <property name="lib.dir" value="${root.dir}/lib"/>
    <property name="files.dir" value="${root.dir}/files"/>
    <property name="src.dir" value="${root.dir}/src"/>

    <!-- Define the source build directories -->
    <property name="doc.apidocs" value="${doc.dir}/api"/>	   	
    <property name="build.dir" value="${root.dir}/build"/>
    <property name="build.lib" value="${root.dir}/build/lib"/>
    <property name="build.files" value="${root.dir}/build/files"/>
    <property name="build.src" value="${root.dir}/build/${name}/src"/>
    <property name="build.dest" value="${root.dir}/build/${name}/classes"/>
        
  </target>

  <!-- =================================================================== -->
  <!-- Help on usage                                                       -->
  <!-- =================================================================== -->
  <target name="usage">
    <echo message=""/>
    <echo message=""/>
    <echo message="Voting Build file"/>
    <echo message="-------------------------------------------------------------"/>
    <echo message=""/>
    <echo message=" available targets are:"/>
    <echo message=""/>
    <echo message="   all             --> builds all the jars in ./build"/>
    <echo message="   voting 		  --> builds the voting.jar file in ./build"/>
    <echo message="   clean           --> restores distribution to original state"/>
    <echo message="   usage           --> (default) displays build menu"/>
    <echo message=""/>
    <echo message=" See the comments inside the build.xml file for more details."/>
    <echo message="-------------------------------------------------------------"/>
    <echo message=""/>
    <echo message=""/>
  </target>

  <!-- =================================================================== -->
  <!-- Prepares the build directory                                        -->
  <!-- =================================================================== -->
  <target name="prepare" depends="init">
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${build.lib}"/>

    <copy todir="${build.lib}">
      <fileset dir="${lib.dir}"/>
    </copy>
    
    <copy todir="${build.files}">
      <fileset dir="${files.dir}"/>
    </copy>

  </target>

  <!-- =================================================================== -->
  <!-- Prepares the source code                                            -->
  <!-- =================================================================== -->
  <target name="prepare-src" depends="prepare">
    <mkdir dir="${build.src}"/>
    <mkdir dir="${build.dest}"/>
   
    <copy todir="${build.src}">
      <fileset dir="${src.dir}"/>
    </copy>

  </target>

  <!-- =================================================================== -->
  <!-- Compiles the source code                                            -->
  <!-- =================================================================== -->
  <target name="compile-src" depends="prepare-src">
    <!-- copy resource files -->
    <copy todir="${build.dest}">
      <fileset dir="${build.src}" excludes="**/*.java"/>
    </copy>

    <javac srcdir="${build.src}"
           destdir="${build.dest}"
           debug="${debug}"
		   classpath="${build.lib}/jdom.jar;${build.lib}/piccolo.jar;${build.lib}/piccolox.jar"
           deprecation="${deprecation}"
           optimize="${optimize}"/>
  </target>


  <!-- =================================================================== -->
  <!-- Creates the source jar in ./build                                   -->
  <!-- =================================================================== -->
  <target name="src" depends="compile-src">
    <jar jarfile="${build.dir}/${name}.jar"
         basedir="${build.dest}"
         manifest="${build.src}/voting.manifest"
         includes="**"/>
  </target>

  <!-- =================================================================== -->
  <!-- Build all jars in ./build                                           -->
  <!-- =================================================================== -->
  <target name="all" depends="src"/>

  <!-- =================================================================== -->
  <!-- Clean restors distribution to original state                        -->
  <!-- =================================================================== -->
  <target name="clean" depends="init">
    <delete dir="${build.dir}"/>
    <delete dir="${doc.apidocs}"/>
  </target>
</project>

<!-- End of file -->