federkasten / appbundle-maven-plugin

Maven plugin that creates an Application Bundle for OS X containing all your project dependencies and the necessary metadata
Apache License 2.0
179 stars 56 forks source link

Java 9+ non-compatibility #59

Open kpepper opened 5 years ago

kpepper commented 5 years ago

I tried running a Maven build with Java 10.0.2 and get the following error from the plugin. It doesn't seem to matter what jvmVersion parameter I specify (even none at all). Specifying an embedded jre doesn't work either, as the jre folder no longer exists in Java 9/10/11 and the plugin tries to copy it. This was using the maven repo version of the plugin.

at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:181)
... 21 more

Caused by: java.lang.ExceptionInInitializerError at sh.tak.appbundler.CreateApplicationBundleMojo.execute(CreateApplicationBundleMojo.java:378) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) ... 21 more Caused by: java.lang.NumberFormatException: multiple points at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1914) at java.base/jdk.internal.math.FloatingDecimal.parseFloat(FloatingDecimal.java:122) at java.base/java.lang.Float.parseFloat(Float.java:455) at org.apache.commons.lang.SystemUtils.getJavaVersionAsFloat(SystemUtils.java:1117) at org.apache.commons.lang.SystemUtils.(SystemUtils.java:817) ... 23 more

cadenkriese commented 5 years ago

I'm getting the same issues on Java 11, @federkasten are you planning on supporting future java versions in this project?

srdubya commented 5 years ago

I got Java 11 working after looking at native/main.m. main.m assumes libjli.dylib is located in <jdk>/Contents/Home/jre/lib/jli/libjli.dylib, but there is no jre folder within the standard JDK-11.0.1 install. The following two manual tasks worked around the issue:

  1. One time: Created the path /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/jre/lib/jli and linked libjli.dylib into it.
  2. After each mvn package: Manually edit Info.plist, setting /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk as the value for the key JVMRuntimePath. This can be done with defaults write <path>/Info.plist JVMRuntimePath /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk

BTW, setting jrePath within pom.xml did not work. Attempting this yielded the following failure when executing mvn package. Rather than investigate this problem and take the size penalty for copying the JRE, I've opted to the above steps.

[ERROR] Failed to execute goal sh.tak.appbundler:appbundle-maven-plugin:1.2.0:bundle (default) on project <project>: Error copying folder /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk to /Users/<user>/Documents/src/<project>/target/<project>-1.0-SNAPSHOT/<project>.app/Contents/PlugIns/JRE/Contents/Home/jre: Failed to copy full contents from /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/jre/lib/jli/libjli.dylib to /Users/<user>/Documents/src/<project>/target/<project>-1.0-SNAPSHOT/<project>.app/Contents/PlugIns/JRE/Contents/Home/jre/lib/jli/libjli.dylib -> [Help 1]

xbiansf commented 5 years ago

Similar issue seen here. Hope to see the fix for this. Even I followed Srdubya's solution, I find the JavaAppLauncher will not work when you launch the Mac App. It will flash one second in the tray and crashes. I used the Mac utility console and dtruss to debug it, but found no useful info why if crashes. Interesting thing is if I open the content of the App and click the inside JavaAppLauncher, the app will launch and uses the openJdk 11 without problem. The Jpackager for