<!--
  ~ build.xml
  ~
  ~ Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
  ~
  ~ This file is part of BEAST.
  ~ See the NOTICE file distributed with this work for additional
  ~ information regarding copyright ownership and licensing.
  ~
  ~ BEAST is free software; you can redistribute it and/or modify
  ~ it under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2
  ~ of the License, or (at your option) any later version.
  ~
  ~  BEAST is distributed in the hope that it will be useful,
  ~  but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~  GNU Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with BEAST; if not, write to the
  ~ Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  ~ Boston, MA  02110-1301  USA
  -->

<!-- Build BEAST MCMC. It is also used by Hudson BEAST_MCMC project. JUnit test is available for this build. -->
<project basedir="." default="build" name="BEAST">
    <description>
        Build BEAST MCMC. It is also used by Hudson BEAST_MCMC project. JUnit test is available for this build.
        $Id$
    </description>

    <property name="JDK_VERSION" value="1.6"/>

    <!-- set global properties for this build -->
    <property name="src" location="src"/>
    <property name="build" location="build"/>
    <property name="lib" location="lib"/>
    <property name="dist" location="${build}/dist"/>

    <property name="main_class_BEAST" value="dr.app.beast.BeastMain"/>
    <property name="main_class_BEAUTI" value="dr.app.beauti.BeautiApp"/>
    <property name="main_class_TRACER" value="dr.app.tracer.application.TracerApp"/>
    <property name="main_class_Annotator" value="dr.app.tools.TreeAnnotator"/>
    <property name="main_class_LogCombiner" value="dr.app.tools.LogCombiner"/>
    <property name="report" value="${build}/junitreport"/>

    <path id="classpath">
        <fileset dir="${lib}" includes="**/*.jar"/>
    </path>

    <!-- start -->
    <target name="init">
        <echo message="${ant.project.name}: ${ant.file}"/>
    </target>

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

    <!-- clean previous build, and then compile Java source code, and Juint test -->
    <target name="test" depends="clean,compile-all,junit"
            description="Clean and Build all run-time stuff with unit test">
    </target>

    <!-- clean previous build, compile Java source code, and Junit test, and make the beast.jar and beauti.jar -->
    <target name="build" depends="clean,compile-all,dist-all"
            description="Clean and Build all and distribute jar">
    </target>

    <!-- compile Java source code -->
    <target name="compile-all" depends="init">
        <mkdir dir="${build}"/>

        <!-- Compile the java code from ${src} into ${build} /bin -->
        <javac source="${JDK_VERSION}" target="${JDK_VERSION}" srcdir="${src}" destdir="${build}"
               classpathref="classpath"
               fork="true"
               memoryinitialsize="256m"
               memorymaximumsize="1024m">
            <include name="dr/app/beast/**"/>
            <include name="dr/app/beauti/**"/>
            <include name="dr/app/bss/**"/>
            <include name="dr/app/tracer/**"/>
            <include name="dr/app/gui/**"/>
            <include name="dr/app/oldbeauti/**"/>
            <include name="dr/app/beagle/**"/>
            <include name="dr/app/seqgen/**"/>
            <include name="dr/app/plugin/**"/>
            <include name="dr/app/tools/**"/>
            <include name="dr/app/util/**"/>
            <include name="dr/app/treestat/**"/>
            <include name="dr/evolution/**"/>
            <include name="dr/evomodel/**"/>
            <include name="dr/evomodelxml/**"/>
            <include name="dr/evoxml/**"/>
            <include name="dr/exporters/**"/>
            <include name="dr/gui/chart/**"/>
            <include name="dr/gui/tree/**"/>
            <include name="dr/inference/**"/>
            <include name="dr/inferencexml/**"/>
            <include name="dr/math/**"/>
            <include name="dr/matrix/**"/>
            <include name="dr/stats/**"/>
            <include name="dr/util/**"/>
            <include name="dr/xml/**"/>
            <include name="dr/geo/**"/>
            <!-- complie JUnit test classes -->
            <include name="test/dr/**"/>
        </javac>
        <echo message="Successfully complied."/>
    </target>

    <!-- make the beast.jar and beauti.jar -->
    <target name="dist-all" depends="compile-all" description="create BEAST + BEAUTI jar">
        <!-- Create the distribution directory -->
        <mkdir dir="${dist}"/>

        <!-- Put everything in ${build} into the beast.jar file -->
        <jar jarfile="${dist}/beast.jar">
            <manifest>
                <attribute name="Built-By" value="${user.name}"/>
                <attribute name="Main-Class" value="${main_class_BEAST}"/>
            </manifest>
            <fileset dir="${build}">
                <include name="dr/app/beast/**/*.class"/>
                <!--<include name="dr/app/beastdev/**/*.class"/>-->
                <include name="dr/app/beauti/**/*.class"/>
                <include name="dr/app/bss/**/*.class"/>
                <include name="dr/app/gui/**/*.class"/>
                <include name="dr/app/seqgen/**"/>
                <include name="dr/app/plugin/**"/>
                <include name="dr/app/util/**/*.class"/>
                <include name="dr/app/tools/**/*.class"/>
                <include name="dr/app/treestat/**/*.class"/>
                <include name="dr/app/beagle/**/*.class"/>
                <!-- include beagle -->
                <include name="dr/evolution/**/*.class"/>
                <exclude name="dr/evomodel/beagle/**"/>
                <include name="dr/evomodel/**/*.class"/>
                <include name="dr/evoxml/**/*.class"/>
                <include name="dr/evomodelxml/**"/>
                <include name="dr/exporters/**/*.class"/>
                <include name="dr/gui/tree/**/*.class"/>
                <include name="dr/inference/**/*.class"/>
                <include name="dr/inferencexml/**/*.class"/>
                <include name="dr/math/**/*.class"/>
                <include name="dr/matrix/**/*.class"/>
                <include name="dr/stats/**/*.class"/>
                <include name="dr/util/**/*.class"/>
                <include name="dr/xml/**/*.class"/>
                <include name="dr/geo/**/*.class"/>
            </fileset>
            <fileset dir="">
                <include name="images/*.png"/>
            </fileset>
            <fileset dir="${src}">
                <include name="dr/**/*.png"/>
                <include name="org/virion/jam/**/*.png"/>
                <include name="dr/**/*.properties"/>
            </fileset>
            <zipgroupfileset dir="${lib}" includes="jebl.jar"/>
            <zipgroupfileset dir="${lib}" includes="jam.jar"/>
            <zipgroupfileset dir="${lib}" includes="jdom.jar"/>
            <zipgroupfileset dir="${lib}" includes="commons-math-2.2.jar"/>
            <zipgroupfileset dir="${lib}" includes="mtj.jar"/>
            <zipgroupfileset dir="${lib}" includes="JRI.jar"/>
            <zipgroupfileset dir="${lib}" includes="colt.jar"/>
            <zipgroupfileset dir="${lib}" includes="beagle.jar"/>
        </jar>

        <!-- Put everything in ${build} into the beauti.jar file -->
        <jar jarfile="${dist}/beauti.jar">
            <manifest>
                <attribute name="Built-By" value="${user.name}"/>
                <attribute name="Main-Class" value="${main_class_BEAUTI}"/>
            </manifest>
            <fileset dir="${build}">
                <include name="dr/app/beast/BeastVersion.class"/>
                <include name="dr/app/beauti/**/*.class"/>
                <include name="dr/app/oldbeauti/**/*.class"/>
                <include name="dr/app/util/**/*.class"/>
                <include name="dr/app/gui/**/*.class"/>
                <include name="dr/app/java16compat/**/*.class"/>
                <include name="dr/evolution/alignment/**/*.class"/>
                <include name="dr/evolution/coalescent/**/*.class"/>
                <include name="dr/evolution/colouring/**/*.class"/>
                <include name="dr/evolution/datatype/**/*.class"/>
                <include name="dr/evolution/distance/**/*.class"/>
                <include name="dr/evolution/io/**/*.class"/>
                <include name="dr/evolution/parsimony/**/*.class"/>
                <include name="dr/evolution/sequence/**/*.class"/>
                <include name="dr/evolution/tree/**/*.class"/>
                <include name="dr/evolution/util/**/*.class"/>
                <include name="dr/evomodel/branchratemodel/**/*.class"/>
                <include name="dr/evomodel/clock/**/*.class"/>
                <include name="dr/evomodel/coalescent/**/*.class"/>
                <include name="dr/evomodel/indel/**/*.class"/>
                <include name="dr/evomodel/operators/**/*.class"/>
                <include name="dr/evomodel/sitemodel/**/*.class"/>
                <include name="dr/evomodel/speciation/**/*.class"/>
                <include name="dr/evomodel/substmodel/**/*.class"/>
                <include name="dr/evomodel/tree/**/*.class"/>
                <include name="dr/evomodel/treelikelihood/**/*.class"/>
                <include name="dr/evomodelxml/**/*.class"/>
                <include name="dr/evoxml/**/*.class"/>
                <include name="dr/gui/chart/**"/>
                <include name="dr/gui/table/**"/>
                <include name="dr/gui/tree/**"/>
                <include name="dr/inference/**/*.class"/>
                <include name="dr/inferencexml/**/*.class"/>
                <include name="dr/math/**/*.class"/>
                <include name="dr/matrix/**/*.class"/>
                <include name="dr/stats/**/*.class"/>
                <include name="dr/util/**/*.class"/>
                <include name="dr/xml/**/*.class"/>
                <include name="dr/geo/**/*.class"/>
            </fileset>
            <fileset dir="">
                <include name="images/*.png"/>
            </fileset>
            <fileset dir="${src}">
                <include name="dr/**/*.png"/>
            </fileset>
            <zipgroupfileset dir="${lib}" includes="jam.jar"/>
            <zipgroupfileset dir="${lib}" includes="jebl.jar"/>
            <zipgroupfileset dir="${lib}" includes="jdom.jar"/>
            <zipgroupfileset dir="${lib}" includes="commons-math-2.2.jar"/>
            <zipgroupfileset dir="${lib}" includes="mtj.jar"/>
        </jar>

    </target>

    <!-- run beast.jar -->
    <target name="run_BEAST">
        <java jar="${dist}/beast.jar" fork="true"/>
    </target>

    <!-- run beauti.jar -->
    <target name="run_BEAUTI">
        <java jar="${dist}/beauti.jar" fork="true"/>
    </target>

    <!-- run beast.jar -->
    <target name="dist_test_jar" depends="dist-all">
        <jar jarfile="${dist}/beastTest.jar">
            <fileset dir="${build}">
                <include name="test/dr/**/*.class"/>
            </fileset>
            <zipgroupfileset dir="${dist}" includes="beast.jar"/>
        </jar>
    </target>

    <!-- JUnit test -->
    <target name="junit">
        <mkdir dir="${report}"/>
        <junit printsummary="yes">
            <classpath>
                <path refid="classpath"/>
                <path location="${build}"/>
            </classpath>

            <formatter type="xml"/>

            <batchtest fork="yes" todir="${report}">
                <fileset dir="${src}">
                    <include name="test/dr/distibutions/**/*Test.java"/>
                    <include name="test/dr/evolution/**/*Test.java"/>
                    <!-- <include name="test/dr/evomodel/**/*Test.java" /> -->
                    <!-- <include name="test/dr/evomodel/arg/**/*Test.java" /> -->
                    <include name="test/dr/evomodel/branchratemodel/**/*Test.java"/>
                    <include name="test/dr/evomodel/coalescent/**/*Test.java"/>
                    <include name="test/dr/evomodel/operators/**/*Test.java"/>
                    <include name="test/dr/evomodel/speciation/**/*Test.java"/>
                    <include name="test/dr/evomodel/substmodel/**/*Test.java"/>
                    <include name="test/dr/evomodel/treelikelihood/**/*Test.java"/>
                    <include name="test/dr/inference/**/*Test.java"/>
                    <include name="test/dr/math/**/*Test.java"/>
                </fileset>
            </batchtest>
        </junit>
        <echo message="JUnit test finished."/>
    </target>

    <target name="junitreport">
        <junitreport todir="${report}">
            <fileset dir="${report}" includes="*.xml"/>
            <report format="frames" todir="${report}"/>
        </junitreport>
        <echo message="JUnit test report finished."/>
    </target>

    <property name="version" value="1.8.3pre"/>
    <property name="version_number" value="1.8.3"/>
    <property name="release_dir" value="release"/>
    <property name="BEAST_name" value="BEAST"/>
    <property name="BEAUti_name" value="BEAUti"/>
    <property name="TreeAnnotator_name" value="TreeAnnotator"/>
    <property name="LogCombiner_name" value="LogCombiner"/>
    <property name="LogAnalyser_name" value="LogAnalyser"/>
    <property name="TreeStat_name" value="TreeStat"/>

    <property name="packaging_tools" value="packaging_tools" />
    <property name="common_dir" value="${release_dir}/common"/>

    <property name="Mac_dir" value="${release_dir}/Mac"/>
    <property name="Linux_dir" value="${release_dir}/Linux"/>
    <property name="Windows_dir" value="${release_dir}/Windows"/>

    <property name="Mac_package_dir" value="${Mac_dir}/${BEAST_name} v${version}"/>
    <property name="Linux_package_dir" value="${Linux_dir}/${BEAST_name}v${version}"/>
    <property name="Windows_package_dir" value="${Windows_dir}/${BEAST_name} v${version}"/>

    <!-- Need to either install Launch4j under {BEAST workspace}/${release}
                  or install it in the default directory and change the location of launch4j.dir -->
    <target name="windows" depends="build"
            description="release Windows version of BEAST, BEAUTI, TreeAnnotator, LogCombiner">

        <delete dir="${Windows_package_dir}"/>
        <!-- Create the release directory -->
        <mkdir dir="${Windows_package_dir}"/>

        <property name="launch4j.dir" location="${Windows_dir}/launch4j"/>
        <taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask"
                 classpath="${launch4j.dir}/launch4j.jar :${launch4j.dir}/lib/xstream.jar"/>

        <copy todir="${Windows_package_dir}/doc">
            <fileset dir="${common_dir}/doc"/>
        </copy>
        <copy todir="${Windows_package_dir}/examples">
            <fileset dir="examples/release"/>
        </copy>
        <copy todir="${Windows_package_dir}/native">
            <fileset dir="native">
                <exclude name="deprecated/**"/>
            </fileset>
        </copy>
        <copy todir="${Windows_package_dir}/bin">
            <fileset dir="${Windows_dir}/scripts"/>
        </copy>
        <copy file="${dist}/beauti.jar" todir="${Windows_package_dir}/lib"/>
        <copy file="${dist}/beast.jar" todir="${Windows_package_dir}/lib"/>
        <!-- <copy file="${dist}/beast-beagle.jar" todir="${Windows_package_dir}/lib"/> -->
        <copy todir="${Windows_package_dir}/lib">
            <fileset dir="${Windows_dir}/lib"/>
        </copy>
        <copy file="${common_dir}/VERSION HISTORY.txt" todir="${Windows_package_dir}"/>
        <copy file="${common_dir}/README.txt" todir="${Windows_package_dir}"/>

        <!-- BEAUTi v?.?.?.exe -->
        <launch4j configFile="${Windows_dir}/BEAUti_launch4j.xml"
                  jar="${dist}/beauti.jar"
                  outfile="${Windows_package_dir}/${BEAUti_name} v${version}.exe"
                  fileVersion="${version_number}.0"
                  txtFileVersion="${version}"
                  productVersion="${version_number}.0"
                  txtProductVersion="${version}"/>

        <!-- BEAST v?.?.?.exe -->
        <launch4j configFile="${Windows_dir}/BEAST_launch4j.xml"
                  jar="${dist}/beast.jar"
                  outfile="${Windows_package_dir}/${BEAST_name} v${version}.exe"
                  fileVersion="${version_number}.0"
                  txtFileVersion="${version}"
                  productVersion="${version_number}.0"
                  txtProductVersion="${version}"/>

        <!-- TreeAnnotator v?.?.?.exe -->
        <launch4j configFile="${Windows_dir}/TreeAnnotator_launch4j.xml"
                  jar="${dist}/beast.jar"
                  outfile="${Windows_package_dir}/${TreeAnnotator_name} v${version}.exe"
                  fileVersion="${version_number}.0"
                  txtFileVersion="${version}"
                  productVersion="${version_number}.0"
                  txtProductVersion="${version}"/>

        <!-- LogCombiner v?.?.?.exe -->
        <launch4j configFile="${Windows_dir}/LogCombiner_launch4j.xml"
                  jar="${dist}/beast.jar"
                  outfile="${Windows_package_dir}/${LogCombiner_name} v${version}.exe"
                  fileVersion="${version_number}.0"
                  txtFileVersion="${version}"
                  productVersion="${version_number}.0"
                  txtProductVersion="${version}"/>

        <launch4j configFile="${Windows_dir}/TreeStat_launch4j.xml"
                  jar="${dist}/beast.jar"
                  outfile="${Windows_package_dir}/${TreeStat_name} v${version}.exe"
                  fileVersion="${version_number}.0"
                  txtFileVersion="${version}"
                  productVersion="${version_number}.0"
                  txtProductVersion="${version}"/>

        <!-- LogAnalyser v?.?.?.exe
          <launch4j configFile="${Windows_dir}/LogAnalyser_launch4j.xml"
                    jar="${dist}/beast.jar"
                    outfile="${Windows_package_dir}/${LogAnalyser_name}v${version}.exe"
                    fileVersion="${version}.0"
                    txtFileVersion="${version}"
                    productVersion="${version}.0"
                    txtProductVersion="${version}"/>	-->

        <zip destfile="${Windows_dir}/${BEAST_name} v${version}.zip">
            <zipfileset dir="${Windows_package_dir}" prefix="${BEAST_name} v${version}"/>
        </zip>

        <echo message="Windows version release is finished."/>
    </target>

    <target name="linux" depends="build"
            description="release Linux/Unix version of BEAST, BEAUTI, TreeAnnotator, LogCombiner">
        <delete dir="${Linux_package_dir}"/>
        <!-- Create the release directory -->
        <mkdir dir="${Linux_package_dir}"/>

        <copy todir="${Linux_package_dir}/bin">
            <fileset dir="${Linux_dir}/scripts"/>
        </copy>
        <chmod dir="${Linux_package_dir}/bin" perm="755" includes="**/**"/>

        <copy todir="${Linux_package_dir}/doc">
            <fileset dir="${common_dir}/doc"/>
        </copy>
        <copy todir="${Linux_package_dir}/examples">
            <fileset dir="examples/release"/>
        </copy>
        <copy todir="${Linux_package_dir}/native">
            <fileset dir="native">
                <exclude name="deprecated/**"/>
            </fileset>
        </copy>

        <copy file="${common_dir}/icons/beast.png" todir="${Linux_package_dir}/images"/>
        <copy file="${common_dir}/icons/beauti.png" todir="${Linux_package_dir}/images"/>
        <copy file="${common_dir}/icons/utility.png" todir="${Linux_package_dir}/images"/>
        <copy file="${dist}/beauti.jar" todir="${Linux_package_dir}/lib"/>
        <copy file="${dist}/beast.jar" todir="${Linux_package_dir}/lib"/>
        <!-- <copy file="${dist}/beast-beagle.jar" todir="${Linux_package_dir}/lib"/> -->
        <copy todir="${Linux_package_dir}/lib">
            <fileset dir="${Linux_dir}/lib"/>
        </copy>
        <copy file="${common_dir}/VERSION HISTORY.txt" todir="${Linux_package_dir}"/>
        <copy file="${common_dir}/README.txt" todir="${Linux_package_dir}"/>

        <!-- Only works under Unix or NonStop Kernel (Tandem) -->
        <!-- <chmod dir="${Linux_package_dir}/bin" perm="755" includes="**/**"/>

		<tar destfile="${Linux_dir}/${BEAST_name}v${version}.tgz" compression="gzip">
			<tarfileset dir="${Linux_package_dir}" prefix="${BEAST_name}v${version}"/>
		</tar>-->
        <!-- [ANT Bug 550] the tar task change the mode of the executables files, have to tar manaully -->
        <echo message="Have to tar manaully, because [ANT Bug 550] the tar task change the mode of the executables files."/>
        <!-- tar -cvzf BEASTv1.x.x.tgz BEASTv1.x.x/ -->
        <!-- cksum BEASTv1.x.x.tgz -->
        <!-- tar -xvzf BEASTv1.x.x.tgz -->
        <echo message="Linux/Unix version release is finished."/>
    </target>

    <target name="mac" depends="build"
            description="release Mac version of BEAST, BEAUTI, TreeAnnotator, LogCombiner">
        <delete dir="${Mac_package_dir}"/>
        <!-- Create the release directory -->
        <mkdir dir="${Mac_package_dir}"/>

        <copy todir="${Mac_package_dir}/bin">
            <fileset dir="${Mac_dir}/scripts"/>
        </copy>
        <chmod dir="${Mac_package_dir}/bin" perm="755" includes="**/**"/>

        <copy todir="${Mac_package_dir}/doc">
            <fileset dir="${common_dir}/doc"/>
        </copy>
        <copy todir="${Mac_package_dir}/examples">
            <fileset dir="examples/release"/>
        </copy>
        <copy todir="${Mac_package_dir}/native">
            <fileset dir="native">
                <exclude name="deprecated/**"/>
            </fileset>
        </copy>

        <copy file="${dist}/beauti.jar" todir="${Mac_package_dir}/lib"/>
        <copy file="${dist}/beast.jar" todir="${Mac_package_dir}/lib"/>
        <!-- <copy file="${dist}/beast-beagle.jar" todir="${Mac_package_dir}/lib"/> -->
        <copy todir="${Mac_package_dir}/lib">
            <fileset dir="${Mac_dir}/lib"/>
        </copy>
        <copy file="${common_dir}/VERSION HISTORY.txt" todir="${Mac_package_dir}"/>
        <copy file="${common_dir}/README.txt" todir="${Mac_package_dir}"/>

        <taskdef name="jarbundler" classname="net.sourceforge.jarbundler.JarBundler"/>

        <!-- create a jar bundle for the mac -->
        <jarbundler dir="${Mac_package_dir}"
                    name="${BEAST_name} v${version}"
                    mainclass="dr.app.beast.BeastMain"
                    stubfile="${packaging_tools}/mac/universalJavaApplicationStub"
                    icon="${common_dir}/icons/beast.icns"
                    jvmversion="1.6+"
                    vmoptions="-d64 -Xmx2048M"
                    arguments="-window -working -options"
                    version="${version}"
                    copyright="${BEAST_name} v${version}, Copyright 2002-2015, Alexei Drummond, Andrew Rambaut and Marc Suchard"
                    bundleid="dr.app.beast">
            <javaproperty name="apple.laf.useScreenMenuBar" value="true"/>
            <javaproperty name="java.library.path" value="$JAVAROOT:/usr/local/lib"/>
            <jarfileset dir="${Mac_package_dir}/lib">
                <include name="**/beast.jar"/>
                <include name="**/beast-beagle.jar"/>
            </jarfileset>
            <jarfileset dir="${Mac_package_dir}/lib">
                <include name="libNucleotideLikelihoodCore.jnilib"/>
            </jarfileset>
        </jarbundler>

        <jarbundler dir="${Mac_package_dir}"
                    name="${BEAUti_name} v${version}"
                    mainclass="dr.app.beauti.BeautiApp"
                    stubfile="${packaging_tools}/mac/universalJavaApplicationStub"
                    icon="${common_dir}/icons/beauti.icns"
                    jvmversion="1.6+"
                    vmoptions="-d64 -Xmx2048M"
                    arguments=""
                    version="${version}"
                    copyright="${BEAUti_name} v${version}, Copyright 2002-2015, Alexei Drummond, Andrew Rambaut, Marc Suchard and Walter Xie"
                    bundleid="dr.app.beauti">
            <documenttype name="BEAUti document"
                          extensions="beauti bti"
                          iconFile="BEAUtiDoc.icns"
                          role="Editor"/>
            <jarfileset dir="${Mac_package_dir}/lib">
                <include name="**/beauti.jar"/>
            </jarfileset>
            <jarfileset dir="${Mac_package_dir}/lib">
                <include name="**/quaqua.jar"/>
            </jarfileset>
            <jarfileset dir="${Mac_package_dir}/lib">
                <include name="libquaqua*.jnilib"/>
            </jarfileset>
            <javaproperty name="apple.laf.useScreenMenuBar" value="true"/>
            <javaproperty name="java.library.path" value="$JAVAROOT"/>
        </jarbundler>

        <jarbundler dir="${Mac_package_dir}"
                    name="${LogCombiner_name} v${version}"
                    mainclass="dr.app.tools.LogCombiner"
                    stubfile="${packaging_tools}/mac/universalJavaApplicationStub"
                    icon="${common_dir}/icons/utility.icns"
                    jvmversion="1.6+"
                    vmoptions="-d64 -Xmx2048M"
                    arguments=""
                    version="${version}"
                    copyright="${LogCombiner_name} v${version}, Copyright 2002-2015, Alexei Drummond, Andrew Rambaut, Marc Suchard and Walter Xie"
                    bundleid="dr.app.tools.logcombiner">
            <jarfileset dir="${Mac_package_dir}/lib">
                <include name="**/beast.jar"/>
            </jarfileset>
            <javaproperty name="apple.laf.useScreenMenuBar" value="true"/>
            <javaproperty name="java.library.path" value="$JAVAROOT/lib"/>
        </jarbundler>

        <jarbundler dir="${Mac_package_dir}"
                    name="${TreeAnnotator_name} v${version}"
                    mainclass="dr.app.tools.TreeAnnotator"
                    stubfile="${packaging_tools}/mac/universalJavaApplicationStub"
                    icon="${common_dir}/icons/utility.icns"
                    jvmversion="1.6+"
                    vmoptions="-d64 -Xmx4096M"
                    arguments=""
                    version="${version}"
                    copyright="${TreeAnnotator_name} v${version}, Copyright 2002-2015, Alexei Drummond, Andrew Rambaut, Marc Suchard and Walter Xie"
                    bundleid="dr.app.tools.treeannotator">
            <jarfileset dir="${Mac_package_dir}/lib">
                <include name="**/beast.jar"/>
            </jarfileset>
            <javaproperty name="apple.laf.useScreenMenuBar" value="true"/>
            <javaproperty name="java.library.path" value="$JAVAROOT/lib"/>
        </jarbundler>

        <jarbundler dir="${Mac_package_dir}"
                    name="${TreeStat_name} v${version}"
                    mainclass="dr.app.treestat.TreeStatApp"
                    stubfile="${packaging_tools}/mac/universalJavaApplicationStub"
                    icon="${common_dir}/icons/TreeStat.icns"
                    jvmversion="1.6+"
                    vmoptions="-d64 -Xmx1024M"
                    arguments=""
                    version="${version}"
                    copyright="${TreeStat_name} v${version}, Copyright 2002-2015, Alexei Drummond and Andrew Rambaut"
                    bundleid="dr.app.treestat">
            <jarfileset dir="${Mac_package_dir}/lib">
                <include name="**/beast.jar"/>
            </jarfileset>
            <javaproperty name="apple.laf.useScreenMenuBar" value="true"/>
            <javaproperty name="java.library.path" value="$JAVAROOT/lib"/>
        </jarbundler>

        <echo message="Building disk image."/>

        <!-- create disk image -->
        <exec executable="/usr/bin/hdiutil">
            <arg value="create"/>
            <arg value="-ov"/>
            <arg value="-srcfolder"/>
            <arg value="${Mac_package_dir}"/>
            <arg value="-volname"/>
            <arg value="${BEAST_name} v${version}"/>
            <arg value="${Mac_dir}/${BEAST_name} v${version}.dmg"/>
        </exec>

        <echo message="Mac version release is finished."/>
    </target>


</project>
