<!-- $Id: build.xml,v 1.28 2009/01/22 23:23:35 joernkottmann Exp $ -->

<!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.    
-->
   	
<project default="package" basedir=".">

  <!-- =================================================================== -->
  <!-- Initialization target                                                                                                                           -->
  <!-- =================================================================== -->
  <target name="init">
    <tstamp/>
    <property name="Name" value="Maxent" />
    <property name="name" value="maxent" />
    <property name="version" value="3.0.0" />
    <property name="year" value="2008"/>

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

    <property name="debug" value="off"/>
    <property name="optimize" value="on"/>
    <property name="deprecation" value="on"/>

    <property name="src.dir" value="./src/main/java"/>
    <property name="lib.dir" value="./lib"/>
    <property name="packages" value="opennlp.maxent.*"/>

    <property name="build.dir" value="./output"/>
    <property name="build.dest" value="${build.dir}/classes"/>
    <property name="build.javadocs" value="./docs/api"/>

    <property name="dist.root" value="./dist"/>
    <property name="dist.dir" value="${dist.root}/${name}-${version}"/>

    <property name="package.dir" value="./package"/>

    <filter token="year" value="${year}"/>
    <filter token="version" value="${version}"/>
    <filter token="date" value="${TODAY}"/>
    <filter token="log" value="true"/>
    <filter token="verbose" value="true"/>

    <path id="build.classpath">
      <pathelement location="${lib.dir}/java-getopt.jar"/>
      <pathelement location="${lib.dir}/trove.jar"/>
    </path>

  </target>

  <!-- =================================================================== -->
  <!-- Help on usage                                                       -->
  <!-- =================================================================== -->
  <target name="usage">
    <echo message=""/>
    <echo message=""/>
    <echo message="Opennlp Maxent build file"/>
    <echo message="-------------------------------------------------------------"/>
    <echo message=""/>
    <echo message=" available targets are:"/>
    <echo message=""/>
    <echo message="   package  --> generates the maxent.jar file (default)"/>
    <echo message="   compile  --> compiles the source code"/>
    <echo message="   javadoc  --> generates the API documentation"/>
    <echo message="   clean    --> cleans up the directory"/>
    <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}"/>
  </target>

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


  <!-- =================================================================== -->
  <!-- Compiles the source directory                                       -->
  <!-- =================================================================== -->
  <target name="compile" depends="prepare-src">
    <javac srcdir="${src.dir}"
           destdir="${build.dest}"
           debug="${debug}"
           classpathref="build.classpath"
           optimize="${optimize}"/>
  </target>


  <!-- =================================================================== -->
  <!-- Creates the class package                                           -->
  <!-- =================================================================== -->
  <target name="package" depends="compile">
    <jar jarfile="${build.dir}/${name}-${version}.jar"
         basedir="${build.dest}" />

  </target>


  <!-- =================================================================== -->
  <!-- Creates Jar file with all other needed jars built in.               -->
  <!-- =================================================================== -->
  <target name="exe" depends="compile">
    <jar jarfile="${build.dir}/${name}-${DSTAMP}.jar"
         basedir="${build.dest}" />
    <jlink outfile="${build.dir}/${name}-exe-${version}.jar">
      <mergefiles>
        <pathelement path="${build.dir}/${name}-${DSTAMP}.jar"/>
	<pathelement location="${lib.dir}/java-getopt.jar"/>
	<pathelement location="${lib.dir}/trove.jar"/>
      </mergefiles>
      <addfiles>
        <pathelement path="META-INF"/>
      </addfiles>
    </jlink>
  </target>


  <!-- =================================================================== -->
  <!-- Creates the release file                                           -->
  <!-- =================================================================== -->
  <target name="release" depends="clean">
    <tar tarfile="${name}-${version}-src.tar"
         basedir="../"
	 includes="${name}/**" >
      <exclude name="${name}/docs/api/**"/>
      <exclude name="**/CVS"/>
    </tar>
    <gzip src="${name}-${version}-src.tar" 
          zipfile="../${name}-${version}-src.tgz" />
    <delete file="${name}-${version}-src.tar" />
  </target>


  <!-- =================================================================== -->
  <!-- Creates the homepage                                                -->
  <!-- =================================================================== -->
  <target name="homepage" depends="init,javadoc">
    <tar tarfile="${name}-homepage.tar"
         basedir="./docs/"
         includes="**"
         excludes="**/CVS" />
    <gzip src="${name}-homepage.tar"
          zipfile="${build.dir}/${name}-homepage.tgz" />
    <delete file="${name}-homepage.tar" />
  </target>


  <!-- =================================================================== -->
  <!-- Creates the API documentation                                       -->
  <!-- =================================================================== -->
  <target name="javadoc" depends="prepare-src">
    <mkdir dir="${build.javadocs}"/>
    <javadoc packagenames="${packages}"
             sourcepath="${src.dir}"
             destdir="${build.javadocs}"
             author="true"
             version="true"
             use="true"
             splitindex="true"
             noindex="false"
             windowtitle="opennlp.${name}"
             doctitle="The OpenNLP ${Name} API v${version}"
             bottom="Copyright &#169; ${year} Jason Baldridge, Gann Bierner, and Thomas Morton. All Rights Reserved."
    />
  </target>


  <!-- =================================================================== -->
  <!-- Clean targets                                                       -->
  <!-- =================================================================== -->
  <target name="clean" depends="init">
    <delete dir="${build.dir}"/>
    <delete file="${docs.dir}/changes.xml"/>
    <delete file="${docs.dir}/todo.xml"/>
    <delete file="${docs.dir}/book.xml"/>
  </target>

  <target name="distclean" depends="clean">
    <deltree dir="${dist.root}"/>
    <delete file="${Name}-${version}.tar.gz"/>
    <delete file="${Name}-${version}.tar"/>
    <delete file="${Name}-${version}.zip"/>
  </target>

</project>