For my little password manager, I’ve long wanted to be able to automate the task of creating a .dmg file for my osx users. In fact, about 18 months ago when I was linking to a page describing the manual process, I was saying this should be ant-able.

Well since I’ve been doing a bunch of betas of the new version, I’m finally sick of creating .dmg files by hand and did some research on what’s required to drive the process from Ant.

The guys at Eclipse have done a sensational job of documenting some interesting mac integration goodies, including the hdiutil app which drives the commandline creation of dmg files. Wrap that guy in a little exec task, and life is pretty darn fine.

In the end, you’ve got something like:

<exec executable="hdiutil">

<arg line="create -srcfolder ${folder.containing.your.app} ${dist.dmg.file}"/>

</exec>

Which creates your dmg file from the folder containing your binary. Does the appropriate compression to ensure the dmg file is only big enough to hold your app. Just the ticket.

Driving all this from Ant makes the osx distro process so much quicker… Big props to the Eclipse dudes for writing this up. Has saved me a ton of time.