<?xml version="1.0" encoding="utf-8"?>
<project name="javakurs" default="compile" basedir="">

  <description>
    This build file provides several targets in the javakurs package.
  </description>

  <!-- set global properties for this build -->
  <property name="classes" value="${basedir}/classes" />
  <property name="docs" value="${basedir}/docs" />
  <property name="data" value="${basedir}/data" />
  <property name="lib" value="${basedir}/lib" />
  <property name="src" value="${basedir}/src" />
  <property name="xslt" value="${basedir}/xslt" />
  <property name="browser"
            location="C:/Programme/Mozilla Firefox/firefox.exe" />
  <property name="doc-index" location="${docs}/index.html" />
  <!-- 
  set default compile options, these are only used when not overridden
  in build.properties 
  -->
  <property file="build.properties" />
  <property name="compile.debug" value="true" />
  <property name="compile.deprecation" value="false" />
  <property name="compile.optimize" value="true" />

  <!-- set java class path -->
  <path id="java.class.path">
    <fileset dir="${lib}" includes="**/*.jar" />
    <pathelement location="${classes}" />
    <pathelement location="${src}" />
  </path>


  <!-- CLEAN target -->
  <target name="clean"
          description="This deletes the classes and docs directories and the JavaCC generated files of exercise 7.">
    <delete dir="${classes}" />
    <delete dir="${docs}" />
    <delete>
      <fileset dir="${src}/javakurs/musterloesung/uebung07"
               includes="FridgeParser.java,FridgeParserConstants.java,FridgeParserTokenManager.java,ParseException.java,SimpleCharStream.java,Token.java,TokenMgrError.java" />
    </delete>
  </target>


  <!-- JAVACC target -->
  <target name="javacc"
          description="This creates a JavaCC Parser from the JavaCC specification in exercise 7">
    <javacc javacchome="${lib}"
            target="${src}/javakurs/musterloesung/uebung07/FridgeParser.jj"
            outputdirectory="${src}/javakurs/musterloesung/uebung07" />
  </target>


  <!-- COMPILE target -->
  <target name="compile"
          depends="javacc"
          description="This compiles the sources of exercise 7.">
    <!-- create new classes directory if required -->
    <mkdir dir="${classes}" />
    <!-- compile the java code from exercise 7 into ${classes} -->
    <javac destdir="${classes}"
           srcdir="${src}"
           debug="${compile.debug}"
           deprecation="${compile.deprecation}"
           optimize="${compile.optimize}"
           includeantruntime="false"
           classpathref="java.class.path">
      <patternset id="exercises">
        <include name="javakurs/musterloesung/uebung07/*.java" />
      </patternset>
    </javac>
  </target>


  <!-- JAVADOC target -->
  <target name="javadoc"
          depends="compile"
          description="This creates the Java docs for exercise 7.">
    <!-- create a new docs directory if required -->
    <mkdir dir="${docs}" />
    <!-- create documentation -->
    <javadoc destdir="${docs}"
             version="true"
             author="true"
             private="false"
             classpathref="java.class.path">
      <fileset dir="${src}">
        <patternset refid="exercises" />
      </fileset>
    </javadoc>
    <!-- show doc in browser -->
    <exec executable="${browser}" spawn="true">
      <arg value="${doc-index}" />
    </exec>
  </target>


  <!-- XPATHTEST -->
  <target name="xpathtest"
          description="This tests the XSLT stylesheet of exercise 3.1.">
    <xslt in="${data}/uebung03/sentences.xml"
          out="${data}/uebung03/XPathTest-Result.txt"
          force="yes"
          style="${xslt}/xpathtest.xsl" />
  </target>


  <!-- CHAINSAW -->
  <target name="chainsaw" description="This starts the chainsaw log4j GUI.">
    <java fork="yes"
          classname="org.apache.log4j.chainsaw.Main"
          classpathref="java.class.path">
      <jvmarg value="-Dchainsaw.port=4445" />
    </java>
  </target>


  <!-- START_FRIDGE -->
  <target name="start_fridge"
          description="This starts the fridge application">
    <java fork="yes"
          classname="javakurs.musterloesung.uebung07.FridgeParser"
          classpathref="java.class.path">
      <jvmarg value="-Dlog4j.configuration=file:conf/log4j.properties" />
    </java>
  </target>

</project>
