<?xml version="1.0" encoding="utf-8" ?>
<project name="BmajWatcher" default="build" basedir=".">
  <!-- Configure path to GWT SDK -->
  <property name="gwt.sdk" location="gwt/" />

  <path id="project.class.path">
    <pathelement location="war/WEB-INF/classes"/>
    <pathelement location="${gwt.sdk}/gwt-user.jar"/>
  	<pathelement location="/usr/share/biomaj/lib/biomaj.jar"/>
    <fileset dir="${gwt.sdk}" includes="*.jar"/>
    <!-- Add any additional non-server libs (such as JUnit) -->
    <fileset dir="war/WEB-INF/lib" includes="**/*.jar"/>
    <fileset dir="/usr/share/java">
    <include name="commons-logging.jar" />
    <include name="commons-lang.jar" />
    <include name="quartz.jar" />
    <include name="xercesImpl.jar" />
    <include name="jdom1.jar" />
    <include name="log4j-1.2.jar" />
    <include name="jsch.jar" />
    <include name="gnumail.jar" />
    </fileset>
  </path>

  <target name="libs" description="Copy libs to WEB-INF/lib">
    <mkdir dir="war/WEB-INF/lib" />
    <copy todir="war/WEB-INF/lib" file="extlib/gwt-cal-0.9.0.jar" />
    <copy todir="war/WEB-INF/lib" file="extlib/gwt-dnd-3.0.1.jar" />
    <copy todir="war/WEB-INF/lib" file="extlib/gwt-visualization.jar" />
    <copy todir="war/WEB-INF/lib" file="extlib/smartgwt.jar" />
    <copy todir="war/WEB-INF/lib" file="extlib/smartgwt-skins.jar" />
    <copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet-deps.jar" />
    <copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet.jar" />
  </target>

  <target name="javac" depends="libs" description="Compile java source">
    <mkdir dir="war/WEB-INF/classes"/>
    <javac srcdir="src" includes="**" encoding="utf-8"
        destdir="war/WEB-INF/classes"
        source="1.5" target="1.5" nowarn="true"
        debug="true" debuglevel="lines,vars,source">
      <classpath refid="project.class.path"/>
    </javac>
    <copy todir="war/WEB-INF/classes">
      <fileset dir="src" excludes="**/*.java"/>
    </copy>
  </target>

  <target name="gwtc" depends="javac" description="GWT compile to JavaScript">
    <java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
      <classpath>
        <pathelement location="src"/>
        <path refid="project.class.path"/>
      </classpath>
      <!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
      <jvmarg value="-Xmx256M"/>
      <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
      <arg value="org.inria.bmajwatcher.BmajWatcher"/>
    </java>
  </target>


  <target name="build" depends="gwtc" description="Build this project" />

  <target name="war" depends="build" description="Create a war file">
    <zip destfile="BmajWatcher.war" basedir="war"/>
  </target>

  <target name="clean" description="Cleans this project">
    <delete dir="war/WEB-INF/classes" failonerror="false" />
    <delete dir="war/WEB-INF/lib" failonerror="false" />
    <delete dir="war/WEB-INF/deploy" failonerror="false" />
    <delete dir="war/bmajwatcher" failonerror="false" />
    <delete file="BmajWatcher.war" failonerror="false" />
  </target>

</project>
