<?xml version="1.0"?>
<!-- Author: Jay Lawson -->
<!-- This is a packaging build file for MekHQ that will package -->
<!-- the following OS-specific releases. -->
<!-- a) An OS X bundled release -->
<!-- b) A Windows release with the EXE file using launch4j -->
<!-- c) A "unix" release containing only jars -->
<!-- d) A source-file only release to comply with GPL -->
<!-- Originally, the OS release was bundled with jarbundler, but I am -->
<!-- now using a pre-packaged set of app directories that we just -->
<!-- copy the newest jar files into. This allows for easier cutomization -->
<!-- of the pinfo.list file to get the classpath to all of the jars -->
<!-- correct. At the moment, I can't figure out how to get a classpath -->
<!-- to the wrapped executable in the launch4j program so MM and MML -->
<!-- in the windows release don't wrap the jar files but we do put them -->
<!-- in the lib folder to keep them out of sight -->
<project default="release" name="MekHQ" basedir=".">
<!-- Global properties for this build -->
<!-- Version and packaging properties -->
<property name="project.name" value="mekhq" />
<property name="version" value="0.3.1"/>
<property name="osxdist" value="${project.name}-${version}-mac" />
<property name="windist" value="${project.name}-${version}-windows" />
<property name="nixdist" value="${project.name}-${version}" />
<property name="srcdist" value="${project.name}-${version}-source" />
<property name="srcdir" value="src" />
<property name="confdir" value="mmconf" />
<property name="logdir" value="logs" />
<property name="builddir" value="classes" />
<property name="libdir" value="lib" />
<property name="datadir" value="data" />
<property name="apidocsdir" value="apidocs" />
<property name="docdir" value="docs" />
<property name="svndir" value="svndev" />
<property name="util" value="packaging_utils" />
<!-- same as builddir but under svn -->
<property name="svnbuilddir" value="${svndir}/${builddir}" />
<!-- svnroot used for svn authentification -->
<property name="svnroot" value="svn://svn.code.sf.net/p/mekhq/code/trunk/MekHQ" />
<property name="svndata" value="svn://svn.code.sf.net/p/megamek/code/trunk/megamek/data" />
<property name="svnrsheets" value="svn://svn.code.sf.net/p/megameklab/code/trunk/data/images/recordsheets" />
<property name="timestampfile" value="${logdir}/timestamp" />
<property name="TinyXMLsrc" value="TinyXML07-src.zip" />
<!-- Name of the target jarfile and the class containing the main-Method -->
<property name="jarfile" value="MekHQ.jar" />
<property name="jarmainclass" value="mekhq.MekHQ" />
<!-- This is the relative path to the 'data' directory -->
<property name="dataclasspath" value="." />
<condition property="isOsUnixLike">
<os family="unix" />
</condition>
<condition property="isOsWindows">
<os family="windows" />
</condition>
<condition property="isOsUnixNotMac">
<and>
<os family="unix" />
<not>
<os family="mac"/>
</not>
</and>
</condition>
<condition property="isOsMac">
<os family="mac" />
</condition>
<taskdef name="jarbundler" classname="net.sourceforge.jarbundler.JarBundler" classpath="${util}/jarbundler-2.1.0.jar"/>
<!-- if we're using a Mac then we'll use the launch4j for Mac OS -->
<target name="checkOSMac" if="isOsMac">
<taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask" classpath="${util}/launch4j/launch4j.jar:${util}/launch4j/lib/xstream.jar" />
</target>
<!-- if we're using UNIX or Linux then we'll use the launch4j for Linux -->
<target name="checkOSUNIX" if="isOsUnixNotMac">
<taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask" classpath="${util}/linux/launch4j/launch4j.jar:${util}/linux/launch4j/lib/xstream.jar" />
</target>
<target name="svndev-init" depends="checkOSMac, checkOSUNIX">
<tstamp />
<delete dir="${svndir}" />
</target>
<!-- following svndev-* tasks get, build & package the current version from svn -->
<target name="svndev-get" depends="svndev-init" description="get the latest source from SVN">
<exec executable="svn">
<arg line="export ${svnroot} ${svndir}" />
</exec>
<!--now we need to replace our data with the latest from the MM svn
but first we need to back it up because we will need to keep a few
things-->
<move file="${svndir}/${datadir}" tofile="${svndir}/${datadir}-OLD"/>
<exec executable="svn">
<arg line="export ${svndata} ${svndir}/${datadir}" />
</exec>
<!-- now add in record sheet vector images-->
<exec executable="svn">
<arg line="export ${svnrsheets} ${svndir}/${datadir}/images/recordsheets" />
</exec>
<!-- ok now move some stuff back into data that needs to be there-->
<copy todir="${svndir}/${datadir}">
<fileset dir="${svndir}/${datadir}-OLD" >
<include name="universe/" />
<include name="fonts/" />
<include name="images/force/" />
<include name="images/portraits/FoxsTeeth/" />
<include name="images/fluff/mech/*.png" />
<include name="images/misc/mekhq-load.png" />
<include name="images/misc/mekhq-splash.png" />
<include name="images/misc/tools.png" />
</fileset>
</copy>
<delete dir="${svndir}/${datadir}-OLD" />
</target>
<target name="svndev-build" depends="svndev-get" description="compile project from SVN and generate JAR file" >
<mkdir dir="${svnbuilddir}" />
<!-- compile -->
<echo message="MekHQ" />
<javac debug="true" debuglevel="lines,source" target="1.5" source="1.5" destdir="${svnbuilddir}" srcdir="${svndir}/${srcdir}" memoryInitialSize="512m" memoryMaximumSize="512m" fork="true">
<classpath>
<pathelement location="${svndir}" />
<fileset dir="${svndir}/${libdir}" includes="*.jar" />
<fileset dir="${svndir}" includes="MegaMek.jar" />
<fileset dir="${svndir}" includes="MegaMekLab.jar" />
</classpath>
</javac>
<!-- jar -->
<jar basedir="${svnbuilddir}" jarfile="${svndir}/${jarfile}" manifest="manifest.txt">
<fileset dir="${svndir}/${srcdir}" includes="**/*.properties"/>
</jar>
<!-- Ensure that the log directory exists. -->
<mkdir dir="${svndir}/${logdir}" />
<touch file="${svndir}/${timestampfile}" />
</target>
<target name="svndev-clean" description="remove the SVN build directory">
<delete dir="${svnbuilddir}" />
</target>
<target name="mac-bundle" description="Bundle the project built from SVN into an Mac OSX distribution">
<mkdir dir="${osxdist}" />
<copy todir="${osxdist}">
<fileset dir="${svndir}" >
<include name="${logdir}/" />
<include name="${datadir}/" />
<include name="${docdir}/" />
<include name="${confdir}/" />
<include name="campaigns/" />
<include name="campaigns/FoxsTeeth.cpnx" />
<include name="*README.html" />
<include name="SubmitBug.html" />
<include name="license.txt" />
</fileset>
</copy>
<mkdir dir="${osxdist}/MegaMek.app" />
<copy todir="${osxdist}/MegaMek.app">
<fileset dir="${util}/MegaMek.app" >
<include name="**/*"/>
</fileset>
</copy>
<copy file="${util}/JavaApplicationStub" todir="${osxdist}/MegaMek.app/Contents/MacOS/"/>
<mkdir dir="${osxdist}/MegaMekLab.app" />
<copy todir="${osxdist}/MegaMekLab.app">
<fileset dir="${util}/MegaMekLab.app" >
<include name="**/*"/>
</fileset>
</copy>
<copy file="${util}/JavaApplicationStub" todir="${osxdist}/MegaMekLab.app/Contents/MacOS/"/>
<mkdir dir="${osxdist}/MekHQ.app" />
<copy todir="${osxdist}/MekHQ.app">
<fileset dir="${util}/MekHQ.app" >
<include name="**/*"/>
</fileset>
</copy>
<copy file="${util}/JavaApplicationStub" todir="${osxdist}/MekHQ.app/Contents/MacOS/"/>
<copy todir="${osxdist}/MekHQ.app/Contents/Resources/Java/">
<fileset dir="${svndir}" >
<include name="${libdir}/*.jar" />
<include name="${jarfile}" />
<include name="MegaMekLab.jar" />
<include name="MegaMek.jar" />
</fileset>
</copy>
</target>
<!-- Replace actual stubs with symlinks on mac systems -->
<target name="mac-stub" if="isOsMac" description="Create a dmg file from the OS X distribution (NOTE: only works on OSX)">
<delete file="${osxdist}/MekHQ.app/Contents/MacOS/JavaApplicationStub" />
<exec executable="ln">
<arg line="-s /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub" />
<arg value="${osxdist}/MekHQ.app/Contents/MacOS/JavaApplicationStub" />
</exec>
<delete file="${osxdist}/MegaMek.app/Contents/MacOS/JavaApplicationStub" />
<exec executable="ln">
<arg line="-s /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub" />
<arg value="${osxdist}/MegaMek.app/Contents/MacOS/JavaApplicationStub" />
</exec>
</target>
<target name="mac-zip">
<tar destfile="${osxdist}.tar.bz2" compression="bzip2" longfile="gnu">
<tarfileset dir="${osxdist}" mode="755" />
</tar>
</target>
<target name="mac-tar" depends="mac-stub,mac-zip" description="Create a compressed tar file of the OS X distribution"/>
<target name="mac-clean">
<delete dir="${osxdist}" />
</target>
<target name="mac-package" depends="mac-bundle, mac-tar, mac-clean" description="Package a Mac OS X distribution of the project built from SVN" />
<target name="nix-bundle" description="Bundle the project built from SVN into a unix distribution">
<mkdir dir="${nixdist}" />
<mkdir dir="${nixdist}/${nixdist}" />
<copy todir="${nixdist}/${nixdist}">
<fileset dir="${svndir}" >
<include name="${jarfile}" />
<include name="${libdir}/*.jar" />
<include name="${logdir}/" />
<include name="${datadir}/" />
<include name="${docdir}/" />
<include name="${confdir}/" />
<include name="campaigns/" />
<include name="campaigns/FoxsTeeth.cpnx" />
<include name="MegaMek.jar" />
<include name="MegaMekLab.jar" />
<include name="*README.html" />
<include name="SubmitBug.html" />
<include name="license.txt" />
<include name="*.sh" />
</fileset>
</copy>
</target>
<target name="nix-tar" description="Create a compressed tar file of the unix distribution">
<tar destfile="${nixdist}.tar.gz" basedir="${nixdist}" compression="gzip" longfile="gnu" />
</target>
<target name="nix-clean">
<delete dir="${nixdist}" />
</target>
<target name="nix-package" depends="nix-bundle, nix-tar, nix-clean" description="Package a Unix distribution of the project built from SVN"/>
<!-- Produce an EXE file -->
<target name="exe" description="Generate an EXE wrappers for MekHQ.jar, MegaMek.jar, and MegaMekLab.jar">
<copy file="${svndir}/MegaMek.jar" tofile="${svndir}/lib/MegaMek.jar"/>
<copy file="${svndir}/MegaMekLab.jar" tofile="${svndir}/lib/MegaMekLab.jar"/>
<delete file="${svndir}/MekHQ.exe"/>
<launch4j configFile="${util}/mekhq.4j.xml" />
<delete file="${svndir}/MegaMek.exe"/>
<launch4j configFile="${util}/megamek.4j.xml" />
<delete file="${svndir}/MegaMekLab.exe"/>
<launch4j configFile="${util}/megameklab.4j.xml" />
</target>
<target name="win-bundle" depends="exe" description="Bundle the project built from SVN into a Windows distribution">
<mkdir dir="${windist}" />
<copy todir="${windist}">
<fileset dir="${svndir}" >
<include name="${libdir}/*.jar" />
<include name="${logdir}/" />
<include name="${datadir}/" />
<include name="${docdir}/" />
<include name="${confdir}/" />
<include name="campaigns/" />
<include name="campaigns/FoxsTeeth.cpnx" />
<!--<include name="MegaMek.jar" />
<include name="MegaMekLab.jar" />-->
<include name="MegaMek.exe" />
<include name="MegaMekLab.exe" />
<include name="MekHQ.exe" />
<include name="*README.html" />
<include name="SubmitBug.html" />
<include name="license.txt" />
</fileset>
</copy>
<copy file="${util}/mekhq.l4j.ini" todir="${windist}"/>
</target>
<target name="win-zip" description="Create a zipfile of the Windows distribution">
<zip zipfile="${basedir}/${windist}.zip" basedir="${windist}" />
</target>
<target name="win-clean">
<delete dir="${windist}" />
<delete file="${svndir}/lib/MegaMek.jar" />
<delete file="${svndir}/lib/MegaMekLab.jar" />
</target>
<target name="win-package" depends="win-bundle, win-zip, win-clean" description="Package a Windows distribution of the project built from SVN"/>
<target name="source-package" description="Package a source-only distribution of the project built from SVN">
<mkdir dir="${srcdist}" />
<mkdir dir="${srcdist}/${srcdist}" />
<copy todir="${srcdist}/${srcdist}">
<fileset dir="${svndir}" >
<exclude name="${builddir}/**"/>
<exclude name="MekHQ.jar"/>
<exclude name="**/*.exe"/>
</fileset>
</copy>
<tar destfile="${srcdist}.tar.gz" basedir="${srcdist}" compression="gzip" longfile="gnu">
</tar>
<delete dir="${srcdist}" />
</target>
<target name="release" depends="svndev-build, mac-package, nix-package, win-package, source-package, svndev-clean" description="Build the project from SVN and package it as Windows, Mac, Unix, and source-only" />
</project>