Tuesday, May 29, 2012

Eclipse-based applications as standard mac application bundle

It's not every day that a 5 digits bug number get's fixed in Eclipse*, so I'm happy to report that the long standing bug 57349 is now fixed in Juno (Eclipse 3.8 / 4.2). It means that you can now deliver eclipse-based applications as mac os x bundled applications.

New layout

For an end user, the biggest change brought here is that the application is now an opaque entity and it has an icon. See screenshot below of the same application to compare.

Now in the details, the new layout pictured on the left mainly differs from the legacy one on the right by two things:
  • the top level folder is now suffixed with .app; thus making the application an opaque entity that requires a special user action to navigate into it (this is also why the left picture does not show the top level folder)
  • the actual launcher included in the Contents folder is included as a child of the top level folder where as in the past it was in a folder whose name was the name of the launcher (e.g. myRCP in the example).

How do you enable this new layout?

  1. Make sure the application you are building uses p2 included in Juno
  2. Move your build environment to use PDE Build from Juno, or Tycho 0.15.
       This will cause the additional metadata necessary to support this new layout to be generated.
  3. When you invoke the p2.director (the one from Juno) to create your application simply suffix the install folder with .app and let the magic happen. If you don't want to keep the legacy shape, don't use the .app suffix. Here is an example of command line: ./eclipse -application org.eclipse.equinox.p2.director -installIU <iufortheproduct> -destination Applications/myCool.app -profile <somename> -repository <therepotoinstalltheproductfrom>

Note to tycho users

Tycho 0.15 (still in snapshot at the time of writing this post) generates the appropriate metadata and p2 repo, but the support to create an installation and archive with the correct layout is not yet released (bug 378021). To obtain the desired shape you can either call the p2 director as mentioned above, or use the workaround provided in bug 378021.

Note to PDE build users

PDE build generates the appropriate metadata and p2 repo, but it will not create an installation and archive with the correct layout. To obtain the desired shape you will have to manually invoke the p2 director as indicated above.

And to conclude I would like to mention that this work has been sponsored by Manumitting Technologies. * Well actually, at this point I count 28 5 digits bug number fixed in Juno and one 4 digits bug number - bug 9503


Oliver Weise said...

Hi Pascal! First thanks for your effort on this. However, I'm not sure if it is still working with Luna. Trying to create a self-contained .app distribution for Mac (on Linux) I see that the only thing inside the "Contents" folder of the generated distro is the eclipse.ini. No executable, no pinfo.list. As I was not able to find any official documentation of this feature: Is it regarded obsolete and no longer maintained?

Pascal said...

Hi Olivier. I have not tried recently but this is still supposed to work. I know it is not the same, but does it work on other platforms? I mean when you build for windows or linux are the files at the right place?

Note that there is going to be more changes in Mars to make the mac layout follow Apple's recommendations which will allow apps to be signed (http://bugs.eclipse.org/431116).