<?xml version="1.0"?>

<!-- build.xml	(C) K. J. Turner	28/09/15 -->

<project name="jasper" default="simulator" basedir=".">

  <property name="source.directory" value="source"/>
  <property name="build.directory" value="build"/>
  <property name="compile.debug" value="true"/>
  <property name="compile.optimize" value="true"/>
  <property name="main.class" value="simulator.ProtocolSimulator"/>
  <property name="simulator.jar" value="html/ProtocolSimulator.jar"/>

  <!-- Uncomment this if you have a keystore and certificate
  <property name="key.pass" value="PASS_WORD"/>
  <property name="store.alias" value="AN_ALIAS"/>
  <property name="store.file" value="FILE_PATH"/>
  <property name="store.pass" value="PASS_WORD"/>
  <property name="timestamp.url" value="TSA_URL"/>
  -->

  <target name="clean" description="Remove build directory and backup files">
     <delete dir="${build.directory}"/>
     <delete>
       <fileset dir="." includes="**/*~ **/*.bak" defaultexcludes="no"/>
     </delete>
  </target>

  <target name="compile" depends="prepare"
   description="Compile source files to build directory">
     <javac srcdir="${source.directory}" destdir="${build.directory}"
       debug="${compile.debug}" optimize="${compile.optimize}"
       includeantruntime="false"/>
  </target>

  <target name="manifest" depends="prepare">
    <tstamp>
      <format property="NOW" pattern="hh:mm dd-MMMM-yyyy" locale="en-gb"/>
    </tstamp>
    <manifest file="${build.directory}/MANIFEST.MF">
      <attribute name="Main-Class" value="${main.class}"/>
      <attribute name="Built-By" value="${user.name}"/>
      <attribute name="Built-On" value="${NOW}"/>
      <attribute name="Permissions" value="sandbox"/>
      <!-- KJT 28/09/15: added for Java 7u51 security change -->
      <attribute name="Caller-Allowable-Codebase" value="*"/>
    </manifest>
  </target>

  <target name="prepare">
     <mkdir dir="${build.directory}"/>
   </target>

  <target name="simulator" depends="compile, manifest"
    description="Build simulator JAR file">
     <jar jarfile="${simulator.jar}" manifest="${build.directory}/MANIFEST.MF">
       <fileset dir="${build.directory}"/>
       <fileset dir="${source.directory}" includes="resources/*.gif"/>
     </jar>
     <!-- Uncomment this if you have a keystore and certificate
     <signjar jar="${simulator.jar}" keystore="${store.file}"
      alias="${store.alias}" storepass="${store.pass}" keypass="${key.pass}"
      tsaurl="${timestamp.url}"/>
     -->
  </target>

  <target name="spotless" depends="clean"
   description="Clean up and remove simulator JAR file">
    <delete file="html/ProtocolSimulator.jar"/>
  </target>

</project>
