<project name="flow-engine" default="all" basedir=".">

   <!-- Properties -->
   <property name="name" value="flow-engine"/>
   <property name="build" value="build"/>
   <property name="build.classes" value="${build}/classes"/>
   <property name="build.doc" value="${build}/api"/>
   <property name="build.lib" value="${build}/lib"/>
   <property name="lib" value="lib"/>
   <property name="build.dist" value="${build}/dist"/>

   <!-- Targets -->
   <!-- Prepare build directories -->
   <target name="prepare">
     <property file="devresource/META-INF/MANIFEST.MF"/>
     <property name="version" value="${Release-Major-Number}.${Release-Minor-Number}.${Release-Milestone-Number}"/>

     <mkdir dir="${build}"/>
     <mkdir dir="${build.classes}"/>
     <mkdir dir="${build.lib}"/>
     <mkdir dir="${build.doc}"/>
   </target>

  <!-- Setup the compile classpath -->
  <path id="classpath">
    <fileset dir="lib">
      <include name="*.jar" />
    </fileset>
  </path>

   <!-- Kill all the created directories -->
   <target name="clean">
     <delete dir="${build}"/>
   </target>

   <!-- Build classes -->
   <target name="classes" depends="prepare">
     <javac srcdir="source" destdir="${build.classes}" debug="off" optimize="on">
       <classpath refid="classpath"/>
       <exclude name="org/jfree/report/modules/gui/swing/**"/>
     </javac>

     <copy todir="${build.classes}">
       <fileset dir="source">
         <include name="**/*.properties"/>
         <exclude name="org/jfree/report/modules/gui/swing/**"/>
       </fileset>
     </copy>
   </target>

   <!-- Build jar archives -->
   <target name="jar" depends="classes">
     <copy file="devresource/META-INF/MANIFEST.MF" tofile="${build}/manifest.tmp" failonerror="false"/>
     <manifest file="${build}/manifest.tmp" mode="update"/>
     <jar jarfile="${build.lib}/${name}.jar" basedir="${build.classes}" manifest="${build}/manifest.tmp"/>
   </target>

   <!-- Build the full JavaDocs -->
   <target name="javadoc" depends="prepare">
     <javadoc sourcepath="source"
             destdir="${build.doc}"
             doctitle="${name} JavaDoc"
             windowtitle="${name} JavaDoc"
             package="true"
             author="true"
             version="true">
       <classpath refid="classpath"/>
       <packageset dir="source">
         <exclude name="org/jfree/report/modules/gui/swing/**"/>
       </packageset>
     </javadoc>
  </target>

  <target name="zip" depends="prepare">
    <mkdir dir="${build.dist}"/>
    <copy todir="${build.dist}/source">
      <fileset dir="source"/>
    </copy>
    <copy todir="${build.dist}/devresource">
      <fileset dir="devresource"/>
    </copy>
    <copy todir="${build.dist}/test">
      <fileset dir="test"/>
    </copy>
    <copy file="build.xml" todir="${build.dist}"/>
    <copy file="licence-LGPL.txt" todir="${build.dist}"/>
    <copy file="README.txt" todir="${build.dist}"/>
    <copy file="ChangeLog.txt" todir="${build.dist}"/>
    <zip destfile="${build}/${name}-${version}.zip" basedir="${build.dist}"/>
  </target>

  <!-- Build everything -->
  <target name="all" depends="jar,javadoc"/>

</project>
