<project name="project" default="compile" basedir=".">


  <property name="app.name"      value="task"/>
  <property name="app.version"   value="1.0"/>
  <property name="compile.debug"   value="true"/>

  <!-- 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">
    <fileset dir="lib/java">
      <include name="*.jar"/>
    </fileset>
    <pathelement path="${build.home}"/>
    <pathelement path="${java.home}/../lib/tools.jar"/>
  </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="clean"
   description="Compile Java sources">

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

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

  </target>

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

		    <java classname="org.benow.java.packager.Packager" fork="true">
      <classpath refid="compile.classpath"/>
			<arg value="--file-add" />
			<arg value="var/templates" />
			<arg value="--output" />
			<arg value="${build.home}" />
    </java>
    <delete file="benow-${app.name}.jar" failonerror="false"/>
    <jar jarfile="benow-${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.*,com.*">
      <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="native" depends="compile"
   description="Compile native code">

	<javah classpath="build" destdir="native/linux" verbose="yes">
	  <class name="org.benow.util.io.ConsoleReader"/>
  	</javah>

	<exec dir="native/linux" executable="make" os="Linux">
	 <env key="java.home" value="${java.home}"/>
	 <env key="os.name" value="linux"/>
	</exec>

<!--
	<exec dir="native" executable="gmake" os="FreeBSD">
	 <env key="java.home" value="${java.home}"/>
	 <env key="os.name" value="freebsd"/>
	</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>


</project>

