<?xml version="1.0"?>
<!-- REBUILD.XML simple holidays 5.2 build that presumes all files are already in the project directory. -->
<!-- Build with ant -f rebuild.xml postzip jet -->
<!-- Compile and jar holidays using ANT -->
<!-- Invoke with [ant clean] to erase class files and start over. -->
<!-- Invoke with [ant compile] to just compile. -->
<!-- Invoke with [ant jar] to compile and create jar files. -->
<!-- Invoke with [ant jet] to create JET executables. -->
<!-- Invoke with [ant zip] to create source code zip files. -->
<!-- Using Apache ANT version 1.10.1 -->
<!-- For details of ANT use, see http://mindprod.com/jgloss/ant.html -->
<!-- This script does not build any *.asm files. -->

<!-- D E F I N I T I O N S -->
<!-- ANT.project.dir is com/mindprod/holidays -->
<!-- basedir is E:/ -->
<project name="holidays" basedir="E:/" default="jar">

<!-- extensions for zip. Case sensitive! Go in zip, not necessarily in Jar. -->
<property name="distributed.exts" value="**/*.au,**/*.asm,**/*.bat,**/*.btm,**/*.c,**/*.COM,**/*.com,**/*.cpp,**/*.css,**/*.csv,**/*.dll,**/*.gif,**/*.h,**/*.hpp,**/*.htm,**/*.html,**/*.ico,**/*.ION,**/*.ion,**/*.jar,**/*.java,**/*.jnlp,**/*.JNLP,**/*.jpg,**/*.look,**/*.png,**/*.properties,**/*.ser,**/*.sln,**/*.txt,**/*.use,**/*.xml" />

<!-- dirs we to exclude from zip. Case sensitive! -->
<property name="nondistributed" value="**/javadoc/**,**/jetpdb/**,**/Debug/**,**/Release/**" />

<!-- C L E A N -->
<target name="clean">
<echo message="    :::    holidays    :::    deleting files to force regeneration." />
  <delete>
    <fileset dir="com/mindprod/holidays" includes="**/*.class" />
    <fileset dir="com/mindprod/holidays" includes="**/*.jar" />
    <!-- leave Jet *.exe. Old versions are still useful during the build. -->
    <fileset dir="com/mindprod/holidays" includes="holidays52.zip" />
  </delete>
</target>

<!-- C O M P I L E -->
<target name="compile">
<echo message="    :::    holidays    :::    compiling Java tree with target=1.8" />
  <javac source="1.8" target="1.8" srcdir="com/mindprod/holidays" sourcepath="${basedir}" classpath="${basedir}" encoding="UTF-8" debug="on" includeAntRuntime="false">
    <compilerarg value="-Xlint:unchecked" />
    <compilerarg value="-Xlint:fallthrough" />
    <compilerarg value="-Xlint:deprecation" />
    <compilerarg value="-Xlint:cast" />
  </javac>
</target>

<!-- J A V A H must do ant javah to rebuild *.h files. -->
<target name="javah" depends="compile">
  <!-- there is no jni -->
</target>

<!-- G A T H E R -->
<target name="gather" depends="compile">
<echo message="    :::    holidays    :::    gathering files to build jar/zip." />
  <!-- prepare holidays.use precis from two pieces -->
    <concat destfile="com/mindprod/holidays/holidays.use" fixlastline="yes">
      <filelist dir="com/mindprod/holidays" files="version.txt,use.txt,versionhistory.txt" />
    </concat>
    <copy file="E:/mindprod/applet/holidays.html" todir="com/mindprod/holidays" failonerror="false" quiet="true" overwrite="true" />
    <copy file="E:/mindprod/applet/holidays.manual.html" todir="com/mindprod/holidays" failonerror="false" quiet="true" overwrite="true" />
    <copy file="E:/mindprod/image/ico/holidays.ico" tofile="E:/mindprod/applet/holidays.ico" failonerror="false" quiet="true" overwrite="true" />
    <copy file="E:/mindprod/image/icon128/holidays.png" tofile="com/mindprod/holidays/holidays.icon128.png" failonerror="false" quiet="true" overwrite="true" />
    <copy file="E:/mindprod/image/icon16/holidays.png" tofile="com/mindprod/holidays/holidays.icon16.png" failonerror="false" quiet="true" overwrite="true" />
    <copy file="E:/mindprod/image/icon32/holidays.png" tofile="com/mindprod/holidays/holidays.icon32.png" failonerror="false" quiet="true" overwrite="true" />
    <copy file="E:/mindprod/image/icon48/holidays.png" tofile="com/mindprod/holidays/holidays.icon48.png" failonerror="false" quiet="true" overwrite="true" />
    <copy file="E:/mindprod/image/icon64/holidays.png" tofile="com/mindprod/holidays/holidays.icon64.png" failonerror="false" quiet="true" overwrite="true" />
    <copy file="E:/mindprod/image/screenshot/holidays.png" tofile="com/mindprod/holidays/holidays.screenshot.png" failonerror="false" quiet="true" overwrite="true" />
    <copy file="E:/mindprod/jdisplay.css" todir="com/mindprod/holidays" failonerror="false" quiet="true" overwrite="true" />
    <copy file="E:/mindprod/mindprod.css" todir="com/mindprod/holidays" failonerror="false" quiet="true" overwrite="true" />
    <copy file="E:/mindprod/pad/holidays.xml" todir="com/mindprod/holidays" failonerror="false" quiet="true" overwrite="true" />
</target>

<!-- J A R -->
<!-- Make F:\Program Files (x86)\apache-ant-1.10.1\lib\GenJar.jar known to ANT -->
<!-- See http://mindprod.com/jgloss/genjar.html for details -->
<taskdef resource="genjar.properties" />

<target name="jar" depends="gather">
<echo message="    :::    holidays    :::    genjar finding dependencies and creating jar." />
  <genjar jarfile="com/mindprod/holidays/holidays.jar">
    <!-- include main class and all its dependencies -->
    <class name="com.mindprod.holidays.Holidays" />
    <!-- Extra classes and properties to include in holidays.jar -->
    <!-- include all the dynamically loaded classes in com.mindprod.holidays dir -->
      <class>
    <fileset dir="${basedir}">
      <include name="com/mindprod/holidays/*.class" />
    </fileset>
    </class>
    <!-- include a properties file as a resource -->
    <resource file="com/mindprod/holidays/Holiday.properties" package="com.mindprod.holidays" />
    <!-- define the manifest -->
    <manifest>
      <attribute name="Main-Class" value="com.mindprod.holidays.Holidays" />
      <attribute name="Application-Name" value="Holidays" />
      <attribute name="Permissions" value="all-permissions" />
    </manifest>
  </genjar>

  <!-- S I G N -->
  <!-- get _your_ password from set jarsignerpassword=sesame -->
  <!-- get _your_ code-signing certificate from set cert=mindprodcert2017rsa -->
  <property environment="env" />
  <signjar jar="com/mindprod/holidays/holidays.jar"
    alias="${env.cert}" keystore="${env.keystore}/.keystore" storepass="${env.jarsignerpassword}"
    tsaurl="http://sha256timestamp.ws.symantec.com/sha256/timestamp" />
  <!-- bundle public key of code signing certificate for zip. -->
  <copy file="E:/mindprod/applet/${env.cert}.cer" todir="com/mindprod/holidays" failonerror="true" overwrite="true" />
  <!-- build exportholidaystocsv.jar -->
  <genjar jarfile="com/mindprod/holidays/exportholidaystocsv.jar">
    <class name="com.mindprod.holidays.ExportHolidaysToCSV" />
    <!-- Extra classes and properties to include in exportholidaystocsv.jar -->
    <!-- include all the dynamically loaded classes in com.mindprod.holidays dir -->
      <class>
    <fileset dir="${basedir}">
      <include name="com/mindprod/holidays/*.class" />
    </fileset>
    </class>
    <!-- include a properties file as a resource -->
    <resource file="com/mindprod/holidays/Holiday.properties" package="com.mindprod.holidays" />
    <!-- define the manifest -->
    <manifest>
      <attribute name="Main-Class" value="com.mindprod.holidays.ExportHolidaysToCSV" />
      <attribute name="Application-Name" value="ExportHolidaysToCSV" />
      <attribute name="Permissions" value="all-permissions" />
    </manifest>
  </genjar>
  <!-- build exportholidaystohtml.jar -->
  <genjar jarfile="com/mindprod/holidays/exportholidaystohtml.jar">
    <class name="com.mindprod.holidays.ExportHolidaysToHTML" />
    <!-- Extra classes and properties to include in exportholidaystohtml.jar -->
    <!-- include all the dynamically loaded classes in com.mindprod.holidays dir -->
      <class>
    <fileset dir="${basedir}">
      <include name="com/mindprod/holidays/*.class" />
    </fileset>
    </class>
    <!-- include a properties file as a resource -->
    <resource file="com/mindprod/holidays/Holiday.properties" package="com.mindprod.holidays" />
    <!-- define the manifest -->
    <manifest>
      <attribute name="Main-Class" value="com.mindprod.holidays.ExportHolidaysToHTML" />
      <attribute name="Application-Name" value="ExportHolidaysToHTML" />
      <attribute name="Permissions" value="all-permissions" />
    </manifest>
  </genjar>
</target>

<!-- P O S T J A R -->
<target name="postjar" depends="jar">
  <!-- nothing to do -->
</target>

<!-- P R E J E T -->
<target name="prejet">
<echo message="    :::    holidays    :::    avoid regenerating Jet executable if already done." />
  <uptodate property="jet.uptodate" targetfile="com/mindprod/holidays/holidays.exe">
    <srcfiles dir="com/mindprod/holidays" includes="*.jar"/>
    </uptodate>
</target>

<!-- J E T -->
<!-- Requires Excelsior JET native Java compiler jc.exe on the path -->
<!-- See http://mindprod.com/jgloss/jet.html for details -->
<target name="jet" depends="prejet" unless="jet.uptodate">
<echo message="    :::    holidays    :::    jet compiling." />
  <exec executable="jc.exe" dir="com/mindprod/holidays">
    <arg value="-DECOR=" />
    <arg value="holidays.jar" />
  </exec>
  <echo message="    :::    holidays/ExportHolidaysToCSV    :::    jet compiling" />
  <exec executable="jc.exe" dir="com/mindprod/holidays">
    <arg value="-DECOR=" />
    <arg value="exportholidaystocsv.jar" />
  </exec>
  <echo message="    :::    holidays/ExportHolidaysToHTML    :::    jet compiling" />
  <exec executable="jc.exe" dir="com/mindprod/holidays">
    <arg value="-DECOR=" />
    <arg value="exportholidaystohtml.jar" />
  </exec>
</target>

<!-- Z I P -->
<target name="zip" depends="jar">
<echo message="    :::    holidays    :::    preparing zip distributable." />
  <!-- Remove references to separate foot files. -->
  <exec executable="prunefoot.exe" failifexecutionfails="false" dir="com/mindprod/holidays">
    <arg value="holidays.html" />
    <arg value="holidays.manual.html" />
  </exec>
  <zip destfile="com/mindprod/holidays/holidays52.zip" duplicate="preserve" filesonly="true" includes="${distributed.exts}" excludes="${nondistributed}">
    <!-- zipfileset includes all subdirs as well -->
    <zipfileset dir="com/mindprod/holidays" prefix="com/mindprod/holidays" includes="${distributed.exts}" excludes="${nondistributed}" />
    <!-- Extra classes and properties to include in the Zip -->
      <zipfileset dir="com/mindprod/common18"    prefix="com/mindprod/common18"    includes="${distributed.exts}" excludes="${nondistributed}" />
      <zipfileset dir="com/mindprod/csv"         prefix="com/mindprod/csv"         includes="${distributed.exts}" excludes="${nondistributed}" />
      <zipfileset dir="com/mindprod/entities"    prefix="com/mindprod/entities"    includes="${distributed.exts}" excludes="${nondistributed}" />
      <zipfileset dir="com/mindprod/fastcat"     prefix="com/mindprod/fastcat"     includes="${distributed.exts}" excludes="${nondistributed}" />
  </zip>
</target>

<!-- P O S T Z I P -->
<target name="postzip" depends="zip,postjar">
  <!-- not distributing a zip -->
</target>
</project>