<project name="benow-java" default="compile" basedir=".">

  <property name="app.name"      value="benow-java"/>
  <property name="app.version"   value="1.0"/>
  <property name="deploy.home"   value="deploy"/>
  <property name="build.home"   value="build/java"/>
  <property name="lib.home"   value="lib/java"/>

  <!-- deploy should be the webapps directory for the servlet container -->
  <property file="/etc/benow/build.properties"/>
  <property file="etc/build.properties"/>


  <path id="compile.classpath">

    <!-- Include all JAR files that will be included in /WEB-INF/lib -->
    <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->

    <!-- Include all needed jars -->
    <fileset dir="${lib.home}">
      <include name="*.jar"/>
    </fileset>
    <pathelement path="${build.home}"/>

  </path>

  <target name="all" depends="clean,jar"
   description="Clean build and dist, then compile"/>

  <target name="clean"
   description="Delete old build directories">
    <delete dir="${build.home}" quiet="yes"/>
    <delete quiet="yes">
      <fileset dir="." includes="**/*~" defaultexcludes="no"/>
    </delete>

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

  <target name="compile" depends="prepare"
   description="Compile Java sources">

    <!-- Compile Java classes as necessary -->
    <javac srcdir="src/java"
          destdir="${build.home}"
           debug="${compile.debug}"
        deprecation="${compile.deprecation}"

        optimize="${compile.optimize}">
        <classpath refid="compile.classpath"/>
    </javac>

  </target>

  <target name="jar" depends="clean,compile"
   description="Create binary distribution">

    <java classname="org.benow.java.packager.Packager" failonerror="true" fork="true">
      <classpath refid="compile.classpath"/>
      <arg value="--md5-include"/>
      <arg value="lib,var,etc/langs.csv"/>
    </java>

    <delete file="${app.name}.jar"/>
    <jar jarfile="${app.name}.jar" basedir="${build.home}" manifest="${build.home}/META-INF/MANIFEST.MF"/>

  </target>

  
<!-- ==================== Javadoc Target ================================== -->

<!--

  The "javadoc" target creates Javadoc API documentation for the Java
  classes included in your application.  Normally, this is only required
  when preparing a distribution release, but is available as a separate
  target in case the developer wants to create Javadocs independently.

-->

  <target name="javadoc" depends="compile"
   description="Create Javadoc API documentation">

    <delete dir="docs/api"/>
    <mkdir          dir="docs/api"/>
    <javadoc sourcepath="src/java"
                destdir="docs/api"
            windowtitle="BeNOW Documentation"
               doctitle="BeNOW Documentation"
           packagenames="org.benow.*,test.*">
      <link href="http://benow.ca/docs/jdk1.4/api/"/>
      <link href="http://benow.ca/docs/xalan-j_2_0_D5/"/>
      <link href="http://benow.ca/docs/xerces-1_2_3/"/>
      <link href="http://benow.ca/docs/xerces-1_2_3/"/>
      <link href="http://benow.ca/docs/jsdk2.2b/"/>
      <classpath refid="compile.classpath"/>
    </javadoc> 

  </target>

  <target name="setup">
    <exec executable="java">
      <arg value="-jar"/>
      <arg value="${lib.home}/benow-launch.jar"/>
      <arg value="Launcher"/>
      <arg value="--make-script"/>
    </exec>
  </target>


<!-- ==================== 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 directory and copy static content -->
    <mkdir  dir="${build.home}"/>

    <!-- Copy static files from external dependencies as needed -->

  </target>

  <!-- recompiles dependencies -->
  <target name="rebuild" description="rebuilds dependencies">
    <ant dir="../castor-accessibility" target="jar" inheritAll="false"/>
    <ant dir="../util" target="jar" inheritAll="false"/>
    <ant dir="../repository" target="jar" inheritAll="false"/>
    <ant dir="../meta" target="jar" inheritAll="false"/>
    <ant dir="." target="compile"/>
  </target>

</project>


