Question

I have built a Java/Swing Application and I have successfully deployed it using Ant, to Windows (using launch4j) and for Mac (using jarbundler ant task). However I want to use Ant to zip the .app along with other files, but since an .app is just a special folder, I am having some problems. Here is my Ant target:

    <property name="jarbundler.dir" location="lib/jarbundler" />
    <taskdef name="jarbundler" 
         classname="net.sourceforge.jarbundler.JarBundler"
         classpath="${jarbundler.dir}/jarbundler-2.2.0.jar"/>
    <target name="app">
        <jarbundler dir="release" name="MobilityCollector" mainclass="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader" jar="mc.jar" icon="img/icon.icns"/>
        <zip destfile="release/MobilityCollector_MacOSX.zip">
            <zipfileset dir="img" prefix="img/"/>
            <zipfileset dir="release/MobilityCollector.app" prefix="MobilityCollector.app"/>
        </zip>
    </target>

Here is the problem:

<zip destfile="release/MobilityCollector_MacOSX.zip">
     <zipfileset dir="img" prefix="img/"/>
     <zipfileset dir="release/MobilityCollector.app" prefix="MobilityCollector.app"/>
</zip>

The problem is that when I run the app (after zippig and unzipping it) it stays bouncing in the dock for ever, and if I click it, it shuts down immediately. I thought that maybe it is a permissions problem, but the permissions are the same as the original app (before zipping) .

Since a .app is a special folder, do I have to zip it in another way? I tryied zipping the way that FailedDev suggested, but it happens anyway.

Was it helpful?

Solution

The problem is in the Ant Zip task when it bundles the .app/Contents/MacOS/JavaApplicationStub. The file permissions are set to 644. This file needs to be executable. You can fix this by specifying the following:

<zip destfile="My-app.zip" level="9">
    <zipfileset filemode="755" dir="basedir" includes="My.app/**/*" />
</zip>

When you change the file mode to the non default of 755 you'll set the JavaApplication stub to be executable, which should stop the bouncing icon in your task bar and actually launch your application.

If this doesn't fix your problem you might try launching the application with your console application running on the mac and see what the log says.

OTHER TIPS

I encountered the same problem with zipping .app bundles. I found out that using the zip utility on the OS X command line works just fine with the .app. Hence my current solution is based on using this tool instead of the ant task:

<exec executable="zip" dir="${basedir}/target">
  <arg value="-r" />
  <arg value="My-app.zip" />
  <arg value="My.app" />
</exec>

This will execute the command zip -r My-app.zip My.app on the command line in the directory ${basedir}/target.

From the documentation :

Resource Collections are used to select groups of files to archive.

Prior to Ant 1.7 only and have been supported as nested elements.

So you can use whatever collection you want e.g. :

<fileset dir="release" includes"MobilityCollector.app/*">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top