Using Ant to build a "proper" MapTool app bundle on OS X

Progress reports and musings from the developers on the current gaming tools.

Moderators: dorpond, trevor, Azhrei

Post Reply
Wordman
Kobold
Posts: 4
Joined: Tue Feb 01, 2011 6:00 pm
Location: Long Island, NY
Contact:

Using Ant to build a "proper" MapTool app bundle on OS X

Post by Wordman »

I like my Mac applications to be double-clickable and living my Applications directory, not a bunch of weird files that use *.command oddities to launch. Since MapTool appears to use Ant for its build process, and Ant is shipped with all Macs, here is how you can build a "real" Mac application out of a MapTool download.

This process works on Snow Leopard. Not sure about other OS versions.

1) Download an Ant task specifically built to make Mac apps out of Java code, called JarBundler.

2) Install the bundle somewhere that Ant can use it. On Snow Leopard, this means copying the jarbundler-2.2.0.jar into /usr/share/ant/lib. You probably will need to use sudo to do this:

Code: Select all

sudo cp ~/Downloads/jarbundler-2.2.0/jarbundler-2.2.0.jar /usr/share/ant/lib/ 
3) Download this collection of supporting files and expand it. It contains:

build.xml - A small Ant script to invoke the jarbundler task with MapTool specific information. (This could be easily moved into the main build file, btw.)
maptool.icns - An ICNS version of the MapTool icon.

4) Download a version of MapTool and expand it. I tested this with version 1.3b75, as that is the version required to use the iPad/iPhone client application MaPnakotic. Could be that other versions need some tweaking.

5) Open a Terminal. Move to the directory of the supporting files. Probably something like:

Code: Select all

cd ~/Downloads/bundleMapTool
7) Figure out the path to the version of MapTool you want to bundle. This is probably something like "~/Downloads/maptool-1.3.b75". We'll call this path $SOURCE for short. (This needds to be the complete path, starting with a slash. No shortcuts, like ~.) Also, we will call the version number $VERSION for short.

6) Run the following command:

Code: Select all

ant -Dmaptool.macbundle.source=$SOURCE -Dmaptool.macbundle.version=$VERSION
...or, for example...

Code: Select all

ant -Dmaptool.macbundle.source=/Users/yourname/Downloads/maptool-1.3.b75 -Dmaptool.macbundle.version=1.3.b75
The end result is a real Mac application:

Image

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Using Ant to build a "proper" MapTool app bundle on OS X

Post by Azhrei »

I'm moving this to the Developer Notes forum since this is not something for the typical MapTool user.


Why are you doing this? There are already OSX-based .dmg files available on the Download page of RPTools.net.

Is there some other reason?

Note that I have an ANT task already defined for MapTool, but it hasn't been integrated into the rest of the build process yet. However, if you're interested in doing this yourself, here's what I have:

Code: Select all

<project name="jarbundler" basedir="." default="bundle">
    <taskdef name="jarbundler"
	 classname="net.sourceforge.jarbundler.JarBundler" />

    <target name="bundle">
	<property name="version" location="1.3.b82" />
	<property name="dist"    location="dist" />
	<property name="source"  location="maptool" />
	<mkdir dir="${dist}" />

	<jarbundler dir="${dist}"
	    name="MapTool"
	    shortname="MapTool"
	    signature="RPTM"
	    icon="maptool-icon.icns"
	    jvmversion="1.5+"
	    version="${version}"
	    bundleid="net.rptools.maptool"
	    arguments="run"
	    vmoptions="-Xmx768m -Xss4m"
	    infostring="RPTools.net MapTool"
	    mainclass="net.rptools.maptool.client.LaunchInstructions">

	    <!--
	    <javaproperty name="apple.laf.useScreenMenuBar" value="true"/>
	    -->

	    <jarfileset dir="${source}">
		<include name="*.jar" />
		<include name="lib/*.jar" />
	    </jarfileset>

	    <resourcefileset dir="${source}">
		<!-- Scripts, XML, and License information for 3pp libraries -->
		<exclude name="**/*.jar" />
		<exclude name="*.bat" />
		<exclude name="*.exe" />
		<exclude name="*.pdf" />
		<exclude name="**/javadoc" />
		<exclude name="**/src" />
	    </resourcefileset>
	</jarbundler>
    </target>
</project>
This is meant to be used against a directory in which the ZIP version has been unpacked. It makes use of a file called maptool-icons.icns to obtain the icon images. The primary problem with it is that I haven't integrated a parameterized version string yet.

(There is an older version of this code in the common-webstart-targets.xml ANT library of the common.build project. You'll need to check out that project from SourceForge to see it though.)

Wordman
Kobold
Posts: 4
Joined: Tue Feb 01, 2011 6:00 pm
Location: Long Island, NY
Contact:

Re: Using Ant to build a "proper" MapTool app bundle on OS X

Post by Wordman »

Azhrei wrote:Why are you doing this? There are already OSX-based .dmg files available on the Download page of RPTools.net.
Ah ha! I didn't see .dmg files for the other tools in the set and, for some reason, just assumed they weren't there for MapTool as well. D'oh!

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Using Ant to build a "proper" MapTool app bundle on OS X

Post by Azhrei »

Ah, okay.

For the Mac, the easiest approach is actually to use Java Web Start. The Launch page on the main site even lets you choose the memory configuration and you can then save the resulting JNLP file and start the tool again later. Since the files are downloaded and cached, you only need an Internet connection for the first load (just like you'd need it to download a ZIP or DMG file).

And you get the benefit of receiving an updated library automatically if there is one. (Although we're not currently using that facility. We probably will in 1.4 or 1.5 though.)

Post Reply

Return to “Developer Notes”