<!-- $Id: ant-build-file.xml,v 1.1.1.1 2004/06/07 18:49:59 scaekenberghe Exp $ -->
<!-- Ant 1.2 build file -->

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

  <!-- set global properties for this build -->
  <property name="src" value="${basedir}/src" />
  <property name="rsrc" value="${basedir}/rsrc" />
  <property name="build" value="${basedir}/bin" />
  <property name="api" value="${basedir}/api" />
  <property name="lib" value="${basedir}/lib" />
  <property name="junit" value="${basedir}/junit" />
  <property name="rsrc" value="${basedir}/rsrc" />
  
  <target name="prepare">
    <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build}" />
    <mkdir dir="${api}" />
    <mkdir dir="${junit}" />
    <copy file="${rsrc}/build/build.version" tofile="${build}/build.properties"/>
    <replace file="${build}/build.properties" token="@@@BUILD_ID@@@" value="${DSTAMP}-${TSTAMP}"/>
  </target>

  <target name="compile" depends="copy-rsrc">
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src}" destdir="${build}" debug="on">
      <classpath>
        <fileset dir="${lib}">
          <include name="log4j-core.jar" />
          <include name="jaxp.jar" />
          <include name="crimson.jar" />
          <include name="jdom.jar" />
          <include name="beanshell.jar" />
        </fileset>
      </classpath>
    </javac>
  </target>

  <target name="compile-junit" depends="copy-rsrc">
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${junit}" destdir="${build}" debug="on">
      <classpath>
        <fileset dir="${lib}">
          <include name="*.jar" />
        </fileset>
      </classpath>
    </javac>
  </target>

  <target name="copy-rsrc" depends="prepare">
    <!-- Copy various resource files into ${build} -->
    <copy todir="${build}">
      <fileset
        dir="${basedir}"
        includes="images/*.gif, images/*.jpg" />
    </copy>
    <copy todir="${build}">
      <fileset
        dir="${src}"
        includes="be/beta9/libretto/data/*.txt" />
    </copy>
    <copy todir="${build}">
      <fileset
        dir="${rsrc}/log4j"
        includes="log4j.properties" />
    </copy>
  </target>
  
  <target name="c-header" depends="compile">
      <javah destdir="${rsrc}/VC_source" class="be.beta9.libretto.io.ParallelPort">
         <classpath>
            <pathelement location="${build}" />
         </classpath>
      </javah>
  </target>
  
  <target name="test-parport" depends="compile">
      <java
      classname="be.beta9.libretto.io.ParallelPortWriter"
      fork="yes">
      <classpath>
        <pathelement location="${build}" />
        <fileset dir="${lib}">
          <include name="*.jar" />
        </fileset>
      </classpath>
    </java>
  </target>
  
  <target name="jar-simple" depends="compile">
    <!-- Put everything in ${build} into the a jar file -->
    <jar
      jarfile="${basedir}/libretto.jar"
      basedir="${build}"
      manifest="${rsrc}/manifest/libretto.mf"/>
  </target>

  <target name="jar" depends="compile">
    <!-- Put everything in ${build} into the a jar file including all dependecies -->
    <unjar src="${lib}/jaxp.jar" dest="${build}" />
    <unjar src="${lib}/crimson.jar" dest="${build}" />
    <unjar src="${lib}/jdom.jar" dest="${build}" />
    <unjar src="${lib}/log4j-core.jar" dest="${build}" />
    <jar
      jarfile="${basedir}/libretto.jar"
      basedir="${build}"
      manifest="${rsrc}/manifest/libretto.mf"/>
  </target>
  
  <target name="client-jar" depends="background-jar">
    <!-- Put everything in ${build} into the a jar file including all dependecies -->
    <unjar src="${lib}/log4j-core.jar" dest="${build}" />
    <jar jarfile="${basedir}/libretto-client.jar" manifest="${rsrc}/manifest/libretto-client.mf">
      <fileset dir="${build}">
        <include name="build.properties"/>
        <include name="log4j.properties"/>
        <include name="be/beta9/libretto/io/*.class"/>
        <include name="be/beta9/libretto/application/Build.class"/>
        <include name="be/beta9/libretto/net/LibrettoTextClient*.class"/>
        <include name="be/beta9/libretto/net/TestClientMessage.class"/>
        <include name="be/beta9/libretto/net/ClientStatusMessageResult.class"/>
        <include name="be/beta9/libretto/net/Client*.class"/>
        <include name="be/beta9/libretto/net/Constants.class"/>
        <include name="be/beta9/libretto/net/TextMessage.class"/>
        <include name="be/beta9/libretto/net/MessageResult.class"/>
        <include name="be/beta9/libretto/net/MessageException.class"/>
        <include name="be/beta9/libretto/net/SingleTextMessage.class"/>
        <include name="be/beta9/libretto/net/Message.class"/>
        <include name="be/beta9/libretto/net/Util.class"/>
        <include name="be/beta9/libretto/gui/ShowSingleTextFrame*.class"/>
        <include name="be/beta9/libretto/gui/AWTTextView*.class"/>
        <include name="be/beta9/libretto/model/AttributedString*.class"/>
        <include name="be/beta9/libretto/model/AWTTextStyle.class"/>
        <include name="be/beta9/libretto/model/LTextStyle.class"/>
        <include name="be/beta9/libretto/model/AWTCharacterAttributes.class"/>
        <include name="be/beta9/libretto/model/Java2DTextStyle.class"/>
        <include name="be/beta9/libretto/model/LCharacterAttributes.class"/>
        <include name="be/beta9/libretto/model/Java2DCharacterAttributes.class"/>
        <include name="be/beta9/libretto/util/TextStyleManager.class"/>
        <include name="be/beta9/libretto/util/Bean.class"/>
        <include name="be/beta9/libretto/util/LibrettoSaxReader.class"/>
        <include name="be/beta9/libretto/util/Preferences.class"/>
        <include name="be/beta9/libretto/util/Utilities.class"/>
        <include name="org/apache/log4j/**"/>
      </fileset>
    </jar>
  </target>
  
  <target name="background-jar" depends="compile">
    <!-- Put everything in ${build} into the a jar file including all dependecies -->
    <jar jarfile="${basedir}/background.jar" manifest="${rsrc}/manifest/background-black-window.mf">
      <fileset dir="${build}">
        <include name="be/beta9/libretto/gui/BackgroundBlackWindow.class"/>
      </fileset>
    </jar>
  </target>

  <target name="run" depends="compile">
    <!-- Execute the main application -->
    <java
      classname="be.beta9.libretto.application.Libretto"
      fork="yes">
      <classpath>
        <pathelement location="${build}" />
        <fileset dir="${lib}">
          <include name="log4j-core.jar" />
          <include name="jaxp.jar" />
          <include name="crimson.jar" />
          <include name="jdom.jar" />
        </fileset>
      </classpath>
    </java>
  </target>

  <target name="debug" depends="compile">
    <!-- Execute the main application in debug mode -->
    <java
      classname="be.beta9.libretto.application.LibrettoDebug"
      fork="yes">
      <classpath>
        <pathelement location="${build}" />
        <fileset dir="${lib}">
          <include name="*.jar" />
        </fileset>
      </classpath>
    </java>
  </target>

  <target name="junit" depends="compile-junit">
    <!-- Execute all junit tests -->
    <java
      classname="be.beta9.libretto.AllTests"
      fork="yes">
      <classpath>
        <pathelement location="${build}" />
        <fileset dir="${lib}">
          <include name="*.jar" />
        </fileset>
      </classpath>
    </java>
  </target>

  <target name="clean">
    <!-- Delete the ${build} directory trees -->
    <delete dir="${build}" />
    <delete dir="${api}" />
  </target>
  
  <target name="api" depends="prepare">
    <!-- Generate javadoc -->
    <javadoc
      packagenames="be.beta9.libretto.*"
      sourcepath="${src}"
      destdir="${api}"
      windowtitle="Libretto"
      author="true"
      version="true"
      use="true"/>
  </target>
  
  <target name="zip-all" depends="jar, client-jar">
    <zip zipfile="libretto.zip">
    <fileset dir="${basedir}">
      <include name="libretto.jar"/>
      <include name="libretto-client.jar"/>
        </fileset>
    </zip>
  </target>

  <target name="upload" depends="clean, zip-all">
    <ftp
      server="users.pandora.be"
      userid="a002458"
      password="bast0s"
      remotedir="libretto"
      verbose="true"
      passive="true">
        <fileset dir="${basedir}">
        <include name="libretto.jar" />
        <include name="libretto-client.jar" />
        <include name="libretto.zip" />
    </fileset>
    </ftp>
  </target>

</project>




