<?xml version="1.0" encoding="iso-8859-1"?>
<project name="statcvs" default="all" basedir=".">
  <property file="project.properties" />
  <property name="project" value="statcvs" />
  <property name="project.path" value="net/sf/statcvs" />
  <property name="project.package" value="net.sf.statcvs" />
  <property name="project.jar" value="statcvs.jar" />
  <property name="src" value="src" />
  <property name="src.tests" value="tests-src" />
  <property name="src.filtered" value="src-temp" />
  <property name="build" value="build" />
  <property name="build.tests" value="build-tests" />
  <property name="jfreechart.jar" value="jfreechart-1.0.13.jar" />
  <property name="jcommon.jar" value="jcommon-1.0.16.jar" />
  <property name="dist" value="dist" />
  <property name="lib" value="lib" />
  <property name="doc" value="doc" />
  <property name="stats" value="stats" />
  <property name="cvs.log" value="cvs.log" />
  <property environment="env" />
  <path id="project.class.path">
    <pathelement path="${java.class.path}" />
    <fileset dir="${lib}">
      <include name="**/*.jar" />
    </fileset>
  </path>
  <target name="clean">
    <!-- Delete all directory trees created by the build file -->
    <delete dir="${src.filtered}" failonerror="false" />
    <delete dir="${build}" failonerror="false" />
    <delete dir="${build.tests}" failonerror="false" />
    <delete dir="${project}" failonerror="false" />
    <delete dir="${dist}" failonerror="false" />
    <delete dir="${doc}" failonerror="false" />
    <delete dir="${stats}" failonerror="false" />
    <delete file="${cvs.log}" failonerror="false" />
  </target>
  <target name="init">
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build}" />
  </target>
  <target name="filter">
    <delete dir="${src.filtered}" failonerror="false" />
    <copy todir="${src.filtered}">
      <fileset dir="${src}" includes="**/*.jar" />
    </copy>
    <copy todir="${src.filtered}">
      <fileset dir="${src}" excludes="**/*.png, **/*.jar" />
      <filterset>
        <filter token="VERSION" value="${statcvs.version}" />
      </filterset>
    </copy>
    <copy todir="${src.filtered}">
      <fileset dir="${src}" includes="**/*.png" />
    </copy>
  </target>
  <target name="compile" depends="init,filter">
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src.filtered}" destdir="${build}" debug="on"
    source="1.4" target="1.4">
      <classpath refid="project.class.path" />
    </javac>
  </target>
  <target name="copyfiles" depends="init">
    <!-- Copies non-class files from source directory to
                        build directory -->
    <copy todir="${build}/${project.path}/">
      <fileset dir="${src.filtered}/${project.path}/">
        <include name="**/*.properties" />
        <include name="**/web-files/*" />
      </fileset>
    </copy>
  </target>
  <target name="run" depends="compile,copyfiles">
    <!-- Runs StatCVS on itself -->
    <java classname="${project.package}.Main" fork="yes">
      <arg line="-verbose -title StatCVS -output-dir ${stats} -notes etc/report-notes.txt -config-file statcvs.properties -viewcvs http://statcvs.cvs.sourceforge.net/statcvs/statcvs -tags 'v.*' -no-developer uid91994 ${cvs.log} ." />
      <classpath>
        <path refid="project.class.path" />
        <pathelement path="${build}" />
      </classpath>
    </java>
  </target>
  <target name="run.dump" depends="compile,copyfiles">
    <!-- Runs StatCVS on itself -->
    <java classname="${project.package}.Main" fork="yes">
      <arg line="-verbose -title StatCVS -output-dir ${stats} -notes etc/report-notes.txt -config-file statcvs.properties -viewcvs http://statcvs.cvs.sourceforge.net/statcvs/statcvs -tags 'v.*' -no-developer uid91994 ${cvs.log} ." />
      <classpath>
        <path refid="project.class.path" />
        <pathelement path="${build}" />
      </classpath>
    </java>
  </target>
  <target name="run.ant" depends="jar">
    <!-- Runs StatCVS on itself, via the Ant task -->
    <taskdef name="statcvs"
    classname="net.sf.statcvs.ant.StatCvsTask"
    classpath="${dist}/${project.jar}" />
    <statcvs title="StatCVS" outputDir="${stats}"
    notes="etc/report-notes.txt"
    viewcvs="http://statcvs.cvs.sourceforge.net/statcvs/statcvs"
    tags="v.*" nodeveloper="uid91994" log="${cvs.log}" path="." />
  </target>
  <target name="run.xml" depends="jar">
    <!-- Runs StatCVS on itself -->
    <java classname="${project.package}.Main" fork="yes">
      <arg line="-verbose -title StatCVS -output-dir ${stats} -notes etc/report-notes.txt -config-file statcvs.properties -viewcvs http://statcvs.cvs.sourceforge.net/statcvs/statcvs -xml -tags 'v.*' -no-developer uid91994 ${cvs.log} ." />
      <classpath>
        <path refid="project.class.path" />
        <pathelement path="${build}" />
      </classpath>
    </java>
  </target>
  <target name="init.tests">
    <!-- Create the build directory structure used by compile.tests -->
    <mkdir dir="${build.tests}" />
  </target>
  <target name="compile.tests" depends="init.tests,compile">
    <!-- Compile the unit tests from ${src.tests} into ${build.tests} -->
    <javac srcdir="${src.tests}" destdir="${build.tests}"
    debug="on" source="1.4" target="1.4">
      <classpath>
        <path refid="project.class.path" />
        <pathelement path="${build}" />
      </classpath>
    </javac>
  </target>
  <target name="copyfiles.tests" depends="init">
    <!-- Copies non-class files from source directory to
                        build directory -->
    <copy todir="${build.tests}/${project.path}/">
      <fileset dir="${src.tests}/${project.path}/">
        <include name="**/*.log" />
        <include name="**/*.log2" />
      </fileset>
    </copy>
  </target>
  <target name="test"
  depends="compile.tests,copyfiles,copyfiles.tests">
    <!-- Runs JUnit tests using the text-only TestRunner -->
    <java classname="junit.textui.TestRunner" fork="yes"
    failonerror="true">
      <arg value="${project.package}.AllTests" />
      <classpath>
        <path refid="project.class.path" />
        <pathelement path="${build}" />
        <pathelement path="${build.tests}" />
      </classpath>
    </java>
  </target>
  <target name="release" depends="clean,jar,javadoc,zip,zip.source"/>
  <target name="jar" depends="test">
    <!-- Creates an executable jar file for the project -->
    <unjar src="${lib}/${jfreechart.jar}" dest="${build}" />
    <unjar src="${lib}/${jcommon.jar}" dest="${build}" />
    <unjar src="${lib}/jdom.jar" dest="${build}" />
    <mkdir dir="${dist}" />
    <jar jarfile="${dist}/${project.jar}" basedir="${build}">
      <manifest>
        <attribute name="Main-Class"
        value="${project.package}.Main" />
      </manifest>
    </jar>
  </target>
  <target name="zip" depends="jar">
    <zip destfile="${dist}/${project}-${statcvs.version}.zip">
      <zipfileset file="${dist}/${project.jar}"
      fullpath="${project}-${statcvs.version}/${project.jar}" />
      <zipfileset file="etc/README"
      fullpath="${project}-${statcvs.version}/readme.txt" />
    </zip>
  </target>
  <target name="zip.source" depends="clean">
    <mkdir dir="${dist}" />
    <zip destfile="${dist}/${project}-${statcvs.version}-source.zip">
      <zipfileset dir="." excludes="${dist}/**,target/**, classes/**, *.bak, test-src/**,test-cvs/**,build/**,build-tests/**,*.log"
      prefix="${project}-${statcvs.version}" />
    </zip>
  </target>
  <target name="javadoc" depends="filter">
    <!-- Creates javadoc documentation for the source
                        (but not for the tests) -->
    <delete dir="${doc}" />
    <mkdir dir="${doc}" />
    <javadoc packagenames="net.*" sourcepath="${src.filtered}"
    destdir="${doc}" classpathref="project.class.path"
    author="true" version="true" private="false" use="true"
    splitindex="true" windowtitle="${project}"
    doctitle="${project}">
      <link href="http://www.jfree.org/jfreechart/api/javadoc/" />
      <link href="http://java.sun.com/j2se/1.4.2/docs/api/" />
    </javadoc>
  </target>
  <target name="cvs.update">
    <!-- Updates from repository. Only works in a checked-out
                        repository with a working local CVS client
                        installation -->
    <cvs command="update -d" />
    <!-- Don't specify -P because we want to retain empty dirs
                        for the log -->
  </target>
  <target name="cvs.log">
    <!-- Saves a cvs log to disk. Only works in a checked-out
                        repository with a working local CVS client
                        installation -->
    <cvs command="log" output="${cvs.log}" />
  </target>
  <target name="all" depends="zip,javadoc,run" />
</project>
