<?xml version="1.0" encoding="utf-8"?>
<project name="netrunner" default="all" basedir=".">
    <description>
        Aglets technology applyed to YACKU moulinette.
    </description>
  <!-- set global properties for this build -->
  <property environment="env"/>
  <property name="src"       location="src"/>
  <property name="build"     location="classes"/>
  <property name="doc"       location="doc"/>
  <property name="lib"       location="lib"/>
  <property name="login"     value="pouill_j"/>
  <property name="java_home" value="${env.JAVA_HOME}"/>
  <property name="args"      value=""/>
 
  <target name="init">
    <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build}"/>
  </target>

  <target name="compile" depends="init"
	  description="compile the source" >
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src}" destdir="${build}" classpath="lib/aglets.jar"/>
  </target>

  <target name="all" depends="compile,doc" />

  <!-- Useless because Tahiti is unable to load classes from jar file -->
  <target name="jar" depends="compile"
	  description="generate the distribution (disable because Tahiti is unable to load classes from jar file)" >
    <!-- Put everything in ${build} into the ${ant.project.name}.jar file -->
    <!--
    <jar jarfile="${ant.project.name}.jar" basedir="public">
      <manifest>
	<attribute name="Built-By" value="${user.name}"/>
	<attribute name="Class-Path" value="lib"/>
	<attribute name="Sealed" value="false"/>
      </manifest>
    </jar>
    -->
  </target>

  <target name="clean"
        description="clean up" >
    <!-- Delete the ${build} and ${doc} directories trees -->
    <delete includeEmptyDirs="true">
      <fileset dir="${build}"/>
      <fileset dir="${doc}"/>
    </delete>
    <!-- Delete the jar archive -->
    <delete file="${ant.project.name}.jar"/>
    <!-- Delete previously created archives -->
    <delete>
      <fileset dir="."> 
        <include name="*.tar*"/>
      </fileset>
    </delete>
    <!-- Recursively delete all *~ *.bak #* -->
    <!-- FIXME: find how to put multiple patterns in one line -->
    <delete>
      <fileset dir="." defaultexcludes="no">
        <include name="**/*~" />
	<include name="**/*.bak"/>
	<include name="**/#*"/>
      </fileset>
    </delete>
  </target>

  <target name="run" depends="jar"
	  description="make a demonstration of program">
    <!-- , use -Dargs='command line'" -->
    <!-- Lunch the jar with the command line arguments -->
    <java classname="com.ibm.awb.launcher.Main" fork="true">
      <arg line="-port 4434"/>
      <jvmarg value="-Daglets.home=."/>
      <jvmarg value="-Daglets.export.path=./classes"/>
      <jvmarg value="-Duser.home=${env.HOME}"/>
       <classpath>
	<pathelement location="lib/aglets.jar"/>
	<pathelement path="./classes"/>
	<pathelement path="."/>
	<pathelement path="${java.class.path}"/>
      </classpath> 
    </java>
   </target>

  <target name="run_ext" depends="jar"
	  description="make a demonstration of program">
    <!-- , use -Dargs='command line'" -->
    <!-- Lunch the jar with the command line arguments -->
    <java classname="com.ibm.awb.launcher.Main" fork="true">
      <arg line="-port 4435"/>
      <jvmarg value="-Daglets.home=."/>
      <jvmarg value="-Daglets.export.path=./classes"/>
      <jvmarg value="-Duser.home=${env.HOME}"/>
       <classpath>
	<pathelement location="lib/aglets.jar"/>
	<pathelement path="./classes"/>
	<pathelement path="."/>
	<pathelement path="${java.class.path}"/>
      </classpath> 
    </java>
   </target>

  <target name="dist" depends="clean"
	  description="package the project">
    <tar destfile="./${login}-${ant.project.name}.tar.bz2" 
	 compression="bzip2">
      <tarfileset dir="${basedir}"
		  prefix="${login}-${ant.project.name}">
	<exclude name="*.tar*"/>
      </tarfileset>
    </tar>
  </target>

  <target name="doc" 
          description="generate the documentation of the project">
    <!-- Lunch javadoc in the src dir and store it in the doc dir -->
    <javadoc packagenames="netrunner.*"
             sourcepath="${src}"
             defaultexcludes="yes"
             destdir="${doc}"
             author="true"
             version="true"
             use="true"
             windowtitle="NetRunner Project Documentation">
      <doctitle><![CDATA[<h1>"NetRunner, EPITA Project, Source Code Documentation"</h1>]]></doctitle>
      <bottom><![CDATA[<i>Copyright &#169; 2000 EPITA. All Rights Reserved.</i>]]></bottom>
    </javadoc>
  </target>

</project>

