wiverson / maven-jpackage-template

Sample project illustrating building nice, small cross-platform JavaFX or Swing desktop apps with native installers while still using the standard Maven dependency system.
Apache License 2.0
351 stars 53 forks source link

Extend template to show how to use dependencies with automatic module name #19

Closed marcin-chwedczuk closed 3 years ago

marcin-chwedczuk commented 3 years ago

Hi,

You did a great job with this template, it saved me a day or two of work. Yet I think the template can be further improved. I use Guava as one of my project dependencies, Guava refused to use JPMS and instead provides only Automatic module name in Manifest.MF. Jlink do not like that and fails with error, my current workaround is to use maven shade plugin and to shade all non modular dependencies into one uber-dependency and then to slap a fake synthetic module-info over it.

You can see the results here: https://github.com/marcin-chwedczuk/img2h (it's still kind of work in progress).

The other remark that I have, is that you explicitly call jlink. Actually the openjfx plugin can call jlink, this is how I do it in my simple tool. I first generate jlink runtime image via openjfx plugin and then I use your plugin to call jpackage.

The last remark is not about library but about creating DMG images. Due to Apple 💩 iness the images are almost useless for average users - the app will not work. The workaround is to first copy the app to Application directory and then to remove all quarantaine attributes like this:

$ cd /Applications
$ sudo xattr -cr img2h.app

This is probably the best we can do without paying $$$ for Apple account.

wiverson commented 3 years ago

The template is specifically built to avoid using modules for user libraries.

https://www.theoryofgeek.com/articles/fomo-java-module-edition

I spent a lot of (very unfun) time trying to get modules to work and has nothing but trouble with ambiguous gains.

This template uses jlink to build a JVM with just the needed JDK and JavaFX modules. Everything else is then brought in as regular JARs on the classpath.

You can sign the generated DMG files, but that is another step (that's also changing in new macOS versions).

You might find these gists helpful:

https://gist.github.com/wiverson/5308a91fcb41a59a0b802e7953891ed9

https://gist.github.com/wiverson/39db914dd21f47648d1ca99064296e5c