Sample Mac Jar Bundler Ant build script

UPDATE: This approach is old and out of date. I’ll update it when I have time.

I was going to write a little tutorial on how to use the Jar Bundler Ant task for Mac OS X, but I don't have the time to do that right now.

So, I'll just share my Mac OS X Java Ant build script, which includes the JarBundler task. You should be able to use this Ant build script to build a Java application so it appears to the user to be a native Mac OS X application, even though it's really a Java application under the covers.

<project name="WikiTeX" default="do_bundle" basedir="..">

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

  <path id="class.path">
    <fileset dir="lib">
      <include name="**/*.jar"/>
      <include name="**/*.zip"/>

  <target name="init">

  <target name="create_classes_dir" depends="init">
    <mkdir dir="classes"/>

  <target name="clean">
    <delete dir="classes"/>

  <target name="compile" depends="clean,create_classes_dir">
    <javac destdir="classes" source="1.5" >
      <src path="src"/>
      <exclude name="**/_*.java"/>
      <classpath refid="class.path"/>
    <copy todir="classes">
      <fileset dir="src">
        <include name="**/*.gif"/>
        <include name="**/*.jpg"/>

  <!-- MAKE_JAR TARGET -->
  <target name="create_jar" depends="compile">
    <copy todir="classes/com/devdaily/opensource/jelly/view">
      <fileset dir="helpfiles">
        <include name="**/*.*"/>
    <jar basedir="classes" jarfile="jar/wikitex.jar" manifest="build/rgadoc.manifest"/>
    <copy todir="jar">
      <fileset dir="lib">
        <include name="**/*.jar"/>
        <include name="**/*.zip"/>

  <target name="do_bundle" depends="create_jar">
    <!-- create a jar bundle for the mac -->
    <jarbundler dir="release"
                signature="Al Alexander"
                infostring="WikiTeX, v0.92, September 2007"
                bundleid="com.devdaily.opensource.jelly.Main" >

      <jarfileset dir="jar">
        <include name="**/*.jar" />
        <exclude name="**/CVS" />

      <javaproperty name="apple.laf.useScreenMenuBar" value="true"/>
      <javaproperty name="apple.awt.brushMetal" value="true"/>
      <javaproperty name="apple.awt.showGrowBox" value="false"/>
      <javaproperty name="" value="WikiTeX"/>
      <javaproperty name="apple.awt.textantialiasing" value="true"/>


One important note is that this Ant build script uses the Mac OS X JarBundler task. That is a separate task that you need to download so you can use this build script (or something like this build script).

Another thing to mention is that this script sets a number of Java properties within the jarbundler task, and all of these properties are Apple/Mac-specific. I've described these properties in other blog posts and tutorials, so if you'll search my site you should be able to find those.