<?xml version="1.0"?>

<project name="j3dall" default="jar" basedir=".">

  <property name="src.dir"       location="src"/>
  <property name="build.dir"     location="build"/>
  <property name="gen.dir"       location="${build.dir}/gen"/>
  <property name="class.dir"     location="${build.dir}/classes"/>

  <property name="j3dtools.dir"      location="../j3dutils"/>
  <property name="j3dtools.src.dir"  location="${j3dtools.dir}/src"/>

  <property name="vecmath.lib"       location="../vecmath/build/jars/vecmath.jar"/>
  <property name="jogl.lib"          location="../../jogl-rc10/jogl-all.jar"/>
  <property name="gluegen.lib"       location="../../jogl-rc10/gluegen.jar"/>
  
  <property name="version_base"             value="1.6.0"/>
  <property name="build.spec.title"         value="3D Graphics API for the Java Platform"/>
  <property name="build.spec.vendor"        value=""/>
  <property name="build.impl.title"         value="3D Graphics API for the Java Platform"/>
  <property name="build.impl.vendor"        value=""/>
  <property name="build.impl.vendor.id"     value=""/>

  <property name="build.type"               value="daily"/>
  <property name="buildtime"                value="daily"/>
  <property name="buildtime_verbose"        value="daily"/>
  <property name="is_dev_phase"             value="true"/>
  <property name="is_production"            value="false"/>
  <property name="use_verbose_buildtime"    value="true"/>
  <property name="version_buildnum"         value="5"/>
  <property name="version_build"            value="pre${version_buildnum}"/>
  <property name="version_suffix"           value="${version_build}"/>

  <target name="clean">
    <delete dir="${build.dir}"/>
  </target>

  <target name="gen">
    <mkdir dir="${gen.dir}"/>

    <copy todir="${gen.dir}"  overwrite="true">
      <fileset dir="${src.dir}/classes"          includes="J3dVersion"/>
      <fileset dir="${j3dtools.src.dir}/classes" includes="ToolsVersion"/>
      <filterset>
        <filter token="VERSION_BASE"    value="${version_base}"/>
        <filter token="SPEC_TITLE"      value="${build.spec.title}"/>
        <filter token="SPEC_VENDOR"     value="${build.spec.vendor}"/>
        <filter token="IMPL_TITLE"      value="${build.impl.title}"/>
        <filter token="IMPL_VENDOR"     value="${build.impl.vendor}"/>
        <filter token="IMPL_VENDOR_ID"  value="${build.impl.vendor.id}"/>
      </filterset>
    </copy>

    <copy todir="${class.dir}/javax">
      <fileset dir="." includes="COPYRIGHT.txt"/>
      <fileset dir="." includes="LICENSE.txt"/>
    </copy>

    <copy todir="${class.dir}/com">
      <fileset dir="${j3dtools.dir}" includes="COPYRIGHT.txt"/>
      <fileset dir="${j3dtools.dir}" includes="*LICENSE*.txt"/>
    </copy>


    <copy file="build-tools/VersionInfo.java"
          todir="${gen.dir}/src/javax/media/j3d"
          overwrite="true">
      <filterset>
        <filter token="BUILD_TYPE"            value="${build.type}"/>
        <filter token="BUILDTIME"             value="${buildtime}"/>
        <filter token="BUILDTIME_VERBOSE"     value="${buildtime_verbose}"/>
        <filter token="IS_DEBUG"              value="false"/>
        <filter token="IS_DEV_PHASE"          value="${is_dev_phase}"/>
        <filter token="IS_PRODUCTION"         value="${is_production}"/>
        <filter token="USE_VERBOSE_BUILDTIME" value="${use_verbose_buildtime}"/>
        <filter token="VERSION_BASE"          value="${version_base}"/>
        <filter token="VERSION_BUILD"         value="${version_build}"/>
        <filter token="VERSION_SUFFIX"        value="${version_suffix}"/>
        <filter token="SPEC_TITLE"            value="${build.spec.title}"/>
        <filter token="SPEC_VENDOR"           value="${build.spec.vendor}"/>
        <filter token="IMPL_TITLE"            value="${build.impl.title}"/>
        <filter token="IMPL_VENDOR"           value="${build.impl.vendor}"/>
      </filterset>
    </copy>
  </target>

  <target name="compile" depends="gen">
    <javac srcdir="${src.dir}/classes/share:${j3dtools.src.dir}/classes/share:${gen.dir}/src"
           destdir="${class.dir}"
           source="1.5"
           target="1.5"
           debug="true"
           debuglevel="lines,source"
           deprecation="off"
           includeantruntime="false"
           classpath="${vecmath.lib}:${jogl.lib}:${gluegen.lib}"/>

    <copy todir="${class.dir}">
      <fileset dir="${src.dir}/classes/share"          includes="**/*.properties"/>
      <fileset dir="${j3dtools.src.dir}/classes/share" includes="**/*.properties"/>
    </copy>
  </target>
  
  <target name="jar" depends="compile">
    <jar jarfile="${build.dir}/jars/j3dcore.jar"
         manifest="${gen.dir}/J3dVersion" update="no" compress="false">
      <fileset dir="${class.dir}" includes="javax/**/*"/>
    </jar>

    <jar jarfile="${build.dir}/jars/j3dutils.jar"
         manifest="${gen.dir}/ToolsVersion" update="no" compress="false">
      <fileset dir="${class.dir}" includes="com/**/*"/>
    </jar>
    
    <zip destfile="${build.dir}/jars/j3dcore-src.zip">
      <fileset dir="${src.dir}/classes/share" includes="javax/**/*.java"/>
      <fileset dir="${gen.dir}/src" includes="javax/**/*.java"/>
      <fileset dir="." includes="COPYRIGHT.txt"/>
      <fileset dir="." includes="LICENSE.txt"/>
    </zip>

    <zip destfile="${build.dir}/jars/j3dutils-src.zip">
      <fileset dir="${j3dtools.src.dir}/classes/share" includes="com/**/*.java"/>
      <fileset dir="${j3dtools.dir}" includes="COPYRIGHT.txt"/>
      <fileset dir="${j3dtools.dir}" includes="*LICENSE*.txt"/>
    </zip>

  </target>
</project>