<?xml version="1.0" ?>

<project
 basedir="."
 default="run"
 name="Thinking in Java, 4th Edition (Refreshed) by Bruce Eckel (chapter: annotations)">

  <description>
    build.xml for the source code for the annotations chapter of
    Thinking in Java, 4th Edition (Refreshed) by Bruce Eckel
    Source code available at http://www.MindView.net
    See copyright notice in CopyRight.txt

    Ant available from: http://ant.apache.org/

    To see options, type: ant -p
  </description>

  <condition property="version1.8">
    <equals arg1="1.8" arg2="${ant.java.version}"/>
  </condition>

  <target name="net_mindview_util">
    <javac includeantruntime="false"
     classpath="${java.class.path};${basedir};${basedir}/.."
     srcdir="${basedir}/../net/mindview/util/">
      <compilerarg value="-Xmaxerrs"/>
      <compilerarg value="10"/>
    </javac>
  </target>

  <target name="net_mindview_atunit">
    <javac includeantruntime="false"
     classpath="${java.class.path};${basedir};${basedir}/.."
     srcdir="${basedir}/../net/mindview/atunit/">
      <compilerarg value="-Xmaxerrs"/>
      <compilerarg value="10"/>
    </javac>
  </target>

  <target
   depends="net_mindview_util,net_mindview_atunit"
   description="Build all classes in this directory"
   name="build">
    <fail message="J2SE8 required" unless="version1.8"/>
    <echo message="Building 'annotations'"/>
    <javac includeantruntime="false"
     classpath="${java.class.path};${basedir};${basedir}/.."
     debug="true"
     srcdir="${basedir}"
     excludes="InterfaceExtractorProcessor.java InterfaceExtractorProcessorFactory.java database/TableCreationProcessorFactory.java">
      <compilerarg value="-Xmaxerrs"/>
      <compilerarg value="10"/>
    </javac>
    <echo message="Build 'annotations' succeeded"/>
  </target>

  <target name="AtUnitComposition">
    <java
     classname="annotations.AtUnitComposition"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../annotations/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="AtUnitExample1">
    <java
     classname="annotations.AtUnitExample1"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../annotations/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="AtUnitExample2">
    <java
     classname="annotations.AtUnitExample2"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../annotations/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="AtUnitExample3">
    <java
     classname="annotations.AtUnitExample3"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../annotations/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="AtUnitExample4">
    <java
     classname="annotations.AtUnitExample4"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../annotations/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="AtUnitExample5">
    <java
     classname="annotations.AtUnitExample5"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../annotations/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="AtUnitExternalTest">
    <java
     classname="annotations.AtUnitExternalTest"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../annotations/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="HashSetTest">
    <java
     classname="annotations.HashSetTest"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../annotations/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Multiplier">
    <java
     classname="annotations.Multiplier"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../annotations/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="StackLStringTest">
    <java
     classname="annotations.StackLStringTest"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../annotations/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="UseCaseTracker">
    <java
     classname="UseCaseTracker"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../annotations/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="TableCreator">
    <java
     classname="annotations.database.TableCreator"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../annotations/database/"
     failonerror="true"
     fork="true">
      <arg line="annotations.database.Member"/>
    </java>
  </target>

  <target name="InterfaceExtractorProcessor">
    <exec executable="apt">
      <arg value="-factory"/>
      <arg
       value="annotations.InterfaceExtractorProcessorFactory"/>
      <arg value="Multiplier.java"/>
      <arg value="-s"/>
      <arg value="../annotations"/>
    </exec>
  </target>

  <target name="TableCreationProcessorFactory">
    <exec executable="apt">
      <arg value="-factory"/>
      <arg
       value="annotations.database.TableCreationProcessorFactory"/>
      <arg value="database/Member.java"/>
      <arg value="-s"/>
      <arg value="database"/>
    </exec>
  </target>

  <target
   depends="build"
   description="Compile and run"
   name="run">
    <touch file="failures"/>
    <antcall target="AtUnitComposition"/>
    <antcall target="AtUnitExample1"/>
    <antcall target="AtUnitExample2"/>
    <antcall target="AtUnitExample3"/>
    <antcall target="AtUnitExample4"/>
    <antcall target="AtUnitExample5"/>
    <antcall target="AtUnitExternalTest"/>
    <antcall target="HashSetTest"/>
    <antcall target="Multiplier"/>
    <antcall target="StackLStringTest"/>
    <antcall target="UseCaseTracker"/>
    <antcall target="TableCreator"/>
    <!-- <antcall target="InterfaceExtractorProcessor"/>
    <antcall target="TableCreationProcessorFactory"/> -->
    <delete file="failures"/>
  </target>

  <target description="delete all byproducts" name="clean">
    <delete>
      <fileset dir="${basedir}" includes="**/*.class"/>
      <fileset dir="${basedir}" includes="**/*Output.txt"/>
      <fileset dir="${basedir}" includes="**/log.txt"/>
      <fileset dir="${basedir}" includes="failures"/>
    </delete>
    <echo message="clean successful"/>
  </target>

</project>