<?xml version="1.0" encoding="ISO-8859-1" ?>


<!--
    This file is part of  JUnitDoclet, a project to generate basic
    test cases  from source code and  helping to keep them in sync
    during refactoring.

    Copyright (C) 2002  ObjectFab GmbH  (http://www.objectfab.de/)

    This library is  free software; you can redistribute it and/or
    modify  it under the  terms of  the  GNU Lesser General Public
    License as published  by the  Free Software Foundation; either
    version 2.1  of the  License, or  (at your option)  any  later
    version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You  should  have  received a  copy of the  GNU Lesser General
    Public License along with this  library; if not, write  to the
    Free  Software  Foundation, Inc.,  59 Temple Place,  Suite 330,
    Boston, MA  02111-1307  USA
-->

<project name="JUnitDocletDemo" default="all" basedir="."  >

  <!-- ============ directory definitions ============== -->

  <!-- Java sources of the application                   -->
  <property name="source"    value="./src"                />

  <!-- for libs like junitdoclet.jar and junit.jar       -->
  <property name="lib"       value="./lib"                />

  <!-- output root                                       -->
  <property name="build"     value="./build"              />

  <!-- Java sources of the unit tests                    -->
  <property name="junit"     value="./junit"              />

  <!-- class files (compiled Java)                       -->
  <property name="classes"   value="${build}/classes"     />


  <!-- ============== testing properties =============== -->
  <property name="package"   value="org.junitdoclet.demo" />
  <property name="testsuite" value="${package}.DemoSuite" />


  <!-- =========== class path for all targets ========== -->
  <path id="classpath_default">
    <pathelement path="${classes}" />
    <!-- the javadoc classes are in this package -->
    <pathelement path="${java.home}/../lib/tools.jar" />

    <fileset dir="${lib}">
       <include name="**/*.jar"/>
    </fileset>
  </path>

  <!--
    Now there are the more usefull tasks:
    clean        - removes everything generated by prior runs
    prepare      - builds the directory structure needed by later steps
    compile      - compiles all *.java files in the source directory
    junitdoclet  - generate test cases based on sources and prior verions of the test cases
    junitcompile - compile test cases (generated and others, just everything in ./junit/ )
    junittest    - execute the main test suite
  -->

  <target name="clean">
    <delete dir="${classes}" />
    <delete dir="${build}"   />
  </target>

  <target name="prepare" depends="clean">
    <mkdir dir="${build}"   />
    <mkdir dir="${classes}" />
    <mkdir dir="${junit}" />
  </target>

  <target name="compile" depends="prepare">
 	<javac srcdir="${source}" destdir="${classes}" debug="on">
      <classpath refid="classpath_default" />
    </javac>
  </target>

  <target name="junitdoclet" depends="compile">
    <javadoc
      packagenames    = "${package}.*"
      sourcepath      = "${source}"
      defaultexcludes = "yes"
      doclet          = "com.objectfab.tools.junitdoclet.JUnitDoclet"
      docletpathref   = "classpath_default"
      additionalparam = "-d ${junit} -buildall">

      <classpath refid = "classpath_default" />
    </javadoc>
  </target>

  <target name="junitcompile" depends="junitdoclet">
 	<javac srcdir="${junit}" destdir="${classes}" debug="on">
      <classpath refid="classpath_default" />
    </javac>
  </target>

  <target name="junittest" depends="junitcompile">
    <junit fork="yes" haltonfailure="no">
      <formatter type="plain" /> <!-- add usefile="no" to write to console -->
      <test name="${testsuite}" outfile="${build}/testresults"/>
      <classpath refid="classpath_default" />
    </junit>
  </target>

  <target name="all" depends="compile, junitdoclet, junitcompile, junittest">
    <!-- C E L E B R A T E -->
  </target>

</project>
