<?xml version="1.0"?>

<!--

  Ant build file for the entire biojava tree
        
  see:
  <a href="http://jakarta.apache.org/ant">Ant Project Homepage</a>
  <a href="http://home.wxs.nl/~ajkuiper/ant.html">Ant User Manual</a>
  <a href="http://jakarta.apache.org/builds/tomcat/nightly/ant.zip">Download</a>
        
  targets:

    compile
    package      builds the biojava.jar file (default)
    javadocs
    dist
    dist-zip    'binary' release (jar & documentation) in zip format
    dist-tgz    'binary' release (jar & documentation) in tar.gz format
    dist-both    both dist-zip & dist-tgz
    clean        cleans up the build & dist directories

  author:  Michael Heuer
  version: $Id: build.xml,v 1.3 2001/02/09 02:47:59 raemig Exp $
        
  portions Copyright (c) 1999-2000 The Apache Software Foundation.
        
-->
        
<project default="package" basedir=".">

  <target name="init">
    <tstamp />
    <property name="name" value="biojava"/>
    <property name="version" value="pre-1.1"/>
                
    <property name="build.compiler" value="classic"/>
        
    <property name="readme" value="./README"/>
    <property name="license" value="./LICENSE"/>
    <property name="src.dir" value="./src"/>
    <property name="manifest.dir" value="./manifest"/>
    <property name="manifest.file" value="defaultmanifest.txt"/>
    <property name="resources.dir" value="./resources"/>

    <property name="classpath" value="xerces.jar:gnu-regexp.jar:bytecode.jar" />

    <property name="packages" value="org.*"/>
        
    <property name="build.dir" value="./ant-build"/>
    <property name="build.src" value="./ant-build/src"/>
    <property name="build.dest" value="./ant-build/classes"/>
    <property name="build.javadocs" value="./ant-build/docs"/>

    <property name="dist.root" value="./dist"/>
    <property name="dist.dir" value="${dist.root}/${name}-${version}"/>
  </target>
        
  <!-- Prepares the build directory -->
  <target name="prepare" depends="init">
    <mkdir dir="${build.dir}"/>
  </target>

  <!-- Prepares the source code -->
  <target name="prepare-src" depends="init,prepare">

    <!-- create directories -->
    <mkdir dir="${build.src}"/>
    <mkdir dir="${build.dest}"/>

    <!-- copy src files -->
    <!-- copydir src="${src.dir}" dest="${build.src}" excludes="CVS,cvs"/ -->
    <copy todir="${build.src}">
      <fileset dir="${src.dir}">
        <exclude name="**/CVS/**" />
      </fileset>
    </copy>

    <!-- copy manifest -->
    <!-- copydir src="${manifest.dir}" dest="${build.src}" includes="${manifest.file}"/ -->
    <copy todir="${build.src}">
      <fileset dir="${manifest.dir}">
        <include name="${manifest.file}" />
      </fileset>
    </copy>

    <!-- copy resources -->
    <!-- copydir src="${resources.dir}" dest="${build.src}" excludes="CVS,cvs"/ -->
    <copy todir="${build.dest}">
      <fileset dir="${resources.dir}">
        <exclude name="**/CVS/**" />
      </fileset>
    </copy>
  </target>
        
  <!-- Compiles the source directory -->
  <target name="compile" depends="init,prepare-src">
    <javac
      srcdir="${build.src}"
      destdir="${build.dest}"
      classpath="${classpath}"
      depend="yes"
    />
  </target>
        
  <!-- Creates the class package -->
  <target name="package" depends="init,compile">
    <jar jarfile="${build.dir}/${name}.jar" basedir="${build.dest}"
         manifest="${build.src}/${manifest.file}" includes="org/**"/>
  </target>
        
  <!-- Creates the API documentation -->
  <target name="javadocs" depends="init,prepare-src">
    <mkdir dir="${build.javadocs}"/>
    <javadoc packagenames="${packages}"
        sourcepath="${build.src}"
        destdir="${build.javadocs}"
        author="true"
        version="true"
        use="true"
        windowtitle="${name} API"
        doctitle="${name}"
    />
  </target>
        
  <!-- Creates the distribution -->
  <target name="dist" depends="init,package,javadocs">
    <mkdir dir="${dist.root}"/>
    <mkdir dir="${dist.dir}"/>
    <mkdir dir="${dist.dir}/lib"/>
    <mkdir dir="${dist.dir}/docs"/>

    <copyfile src="${readme}" dest="${dist.dir}"/>
    <copyfile src="${license}" dest="${dist.dir}"/>
 
    <copyfile src="${build.dir}/${name}.jar" dest="${dist.dir}/lib/${name}.jar"/>
    <copydir src="${build.javadocs}" dest="${dist.dir}/docs"/>
  </target>

  <!-- zips the dist -->
  <target name="dist-zip" depends="init,dist">
    <zip zipfile="${name}-${version}.zip" basedir="${dist.dir}" includes="**"/>
  </target>

  <!-- tgzs the dist -->
  <target name="dist-tgz" depends="init,dist">
    <tar tarfile="${name}-${version}.tar" basedir="${dist.root}" includes="**"/>
    <gzip zipfile="${name}-${version}.tar.gz" src="${name}-${version}.tar"/>
  </target>

  <!-- zip & tgz -->
  <target name="dist-both" depends="init,dist-zip,dist-tgz"/>

  <!-- Cleans everything -->
  <target name="clean" depends="init">
    <deltree dir="${build.dir}"/>
    <deltree dir="${dist.root}"/>
    <delete file="${name}-${version}.tar.gz"/>
    <delete file="${name}-${version}.tar"/>
    <delete file="${name}-${version}.zip"/>
  </target>

  <target name="sync">
    <cvs command="update" />
    <AntCall target="package"/>
    <cvs command="commit" />
  </target>

</project>
