Saturday, April 11, 2020

Glimmer 0.5.2 Packaging Desktop Apps as Mac DMG bundles

Glimmer desktop apps written in Ruby can be packaged easily for distribution on the Mac, Windows, and Linux using both of these tools:
- Warbler (https://github.com/jruby/warbler): Enables bundling a Glimmer app into a JAR file
- javapackager (https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html): Enables packaging Glimmer JAR file (output of Warbler) as a DMG (and PKG) file on Mac, EXE on Windows, and multiple Linux supported formats on Linux.

Newly shipped Glimmer 0.5.2 (https://github.com/AndyObtiva/glimmer/tree/v0.5.2) simplifies the process for packaging on the Mac by automating the work via a rake task.

To leverage rake task:
- Create `Rakefile` in your app root directory
- Add the following line to it: `require 'glimmer/rake_task'`
- Create a Ruby script under `bin` to launch your application (e.g. `bin/math_bowling`) with the following content (replacing `'../app/my_application.rb'` with your application path):
require 'glimmer/launcher'
require Glimmer::Launcher.swt_jar_file
require_relative '../app/my_application.rb'


Now, you can run the following command to package your app into a Mac DMG (and PKG) file (using both Warbler and javapackager):

rake glimmer:package


This will automatically generate a JAR file under `./dist` directory and DMG (and PKG) file under `./packages/bundles`. Both will match your application local directory name (e.g. `MathBowling.jar` and `MathBowling-1.0.dmg` for `~/code/MathBowling`)

By default, the package only includes these directories: app, config, db, lib, script, bin, images, sounds, videos

After running once, you will find a `config/warble.rb` file. It has the JAR packaging configuration. You may adjust included directories in it if needed, and then rerun `rake glimmer:package` and it will pick up your custom configuration.

Otherwise, you may find more advanced instructions for javapackager (https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html#BCGICFDB) and (https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html) in order to sign your Mac app and distribute on the App Store.

Additionally, read their documentation on how to set an icon/assets for the application: https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html

Last but not least, this actual Glimmer project is using the new packaging rake task feature already: https://github.com/AndyObtiva/MathBowling

You may download its DMG file over here (also mentioned on project page): https://srv-file12.gofile.io/download/x8rV9d/MathBowling-1.0.dmg

No comments: