crotwell / gradle-macappbundle

A Gradle Plugin to create a Mac OSX .app application and dmg based on the project.
Apache License 2.0
96 stars 33 forks source link

JDK 10 is not bundled #56

Open schw4rzlicht opened 6 years ago

schw4rzlicht commented 6 years ago

I am trying to bundle a JavaFX application for macOS using JDK 10, Gradle 4.6.0 and plugin version 2.2.1. When bundleJRE = false, everything seems to work and I can start the app (because JDK 10 is installed locally). When set to true, the JDK doesn't seem to be bundled to the app unfortunately, so starting the app results in a JRELoadError.

The corresponding directory in the app bundle is empty:

bildschirmfoto 2018-04-09 um 17 14 41

What am I missing here?

crotwell commented 6 years ago

I have not tried with java10, so not sure.

Do you have jreHome set as well? If not does /usr/libexec/java_home give the correct path for java10?

This is a simple copy of the jre, so if java10 is installed in a different way from previous versions it may not work.

schw4rzlicht commented 6 years ago

Do you have jreHome set as well?

No.

If not does /usr/libexec/java_home give the correct path for java10?

Yes, it points to /Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home:

julian$ /usr/libexec/java_home 
/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home
julian$ cd /Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home
julian$ ls -l
total 16
-r--r--r--    1 root  wheel   158  8 Mär 03:16 README.html
drwxr-xr-x   48 root  wheel  1536  8 Mär 03:20 bin
drwxr-xr-x    7 root  wheel   224  8 Mär 03:16 conf
drwxr-xr-x   11 root  wheel   352  8 Mär 03:16 include
drwxr-xr-x  100 root  wheel  3200  8 Mär 03:16 jmods
drwxr-xr-x  101 root  wheel  3232  8 Mär 03:16 legal
drwxr-xr-x   90 root  wheel  2880  8 Mär 03:16 lib
-rw-r--r--    1 root  wheel  1653  8 Mär 03:16 release

Looks good to me on first glance.

crotwell commented 6 years ago

That is the difference, under previous versions of java, there was a directory called jre inside Contents/Home that contained all that was needed to run java. Obviously you do not want to include the entire jdk when all you need is the jre. Guess I will have to rethink how that works if this is how newer jdk's will be distributed.

A bit of a pain, but in the meantime if you can figure out what files you need to include, you can create a directory that is a "fake" jre and set jreHome to that. The directory should contain: Contents/Home/jre where you set jreHome to be the 'jre' subdirectory inside. The task will go up two levels and so copy effectively <jreHome>/../../Contents/Home/jre/** along with <jreHome>/../../Contents/Info.plist into the project.

Alternatively, you could set up your own gradle Sync task to put stuff in the right place and have createApp.dependsOn('myJreCopyTask').

Likely there are other issues if they really have changed the directory layout significantly. Please let me know what you find out if you do try this.

schw4rzlicht commented 6 years ago

It looks like JDK 9 is also affected and the directory structure you mentioned was changed in that version already. According to https://docs.oracle.com/javase/9/install/installed-directory-structure-jdk-and-jre.htm, the JRE is installed in /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/.

I will have a closer look later, just wanted to report back.

benzoid commented 6 years ago

Hi, (obviously) this effects Java 11 too. This might now be a more urgent problem with Java 11 the now current (and LTS) release, and Java 8 on the way out. Thanks!

crotwell commented 5 years ago

I've done some reading and looks like bundling the jre has changed significantly in java after8 and even more after 9 and this should probably be done with jlink as opposed to just copying a directory into the app.

Josh-Larson commented 5 years ago

Perhaps it could work if you copied the results from jlink into the app, and ran the correct script (bin/)?