-
Notifications
You must be signed in to change notification settings - Fork 4
[WIP] Java11 migration #45
base: main
Are you sure you want to change the base?
Conversation
Using the following patch, I get a jar that starts the GUI with java 11:
Got the implementation from https://openjfx.io/openjfx-docs/#modular (see the Non-Modular project section) and disabled the jar signature check with https://stackoverflow.com/a/6743609 I noticed it doesn't do a splash screen anymore. Is this a good way forward or do we need something else ? $ git diff
diff --git a/gse-demo/pom.xml b/gse-demo/pom.xml
index c94249e..9ba034e 100644
--- a/gse-demo/pom.xml
+++ b/gse-demo/pom.xml
@@ -57,35 +57,35 @@
</executions>
</plugin>
<plugin>
- <groupId>com.zenjava</groupId>
- <artifactId>javafx-maven-plugin</artifactId>
- <version>${maven.javafx.version}</version>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>${maven.shade.version}</version>
<configuration>
- <vendor>PowSyBl</vendor>
- <appName>gse</appName>
- <nativeReleaseVersion>${project.version}</nativeReleaseVersion>
- <mainClass>com.powsybl.gse.demo.GseDemo</mainClass>
- <skipJNLP>true</skipJNLP>
- <jvmProperties>
- <app.root>$APPDIR</app.root>
- <powsybl.config.dirs>${user_home}/.powsybl:${app.root}/app</powsybl.config.dirs>
- <javafx.preloader>com.powsybl.gse.app.GsePreloader</javafx.preloader>
- </jvmProperties>
+ <shadedArtifactAttached>true</shadedArtifactAttached>
+ <shadedClassifierName>project-classifier</shadedClassifierName>
+ <outputFile>target/shade/${project.artifactId}.jar</outputFile>
+ <filters>
+ <filter>
+ <artifact>*:*</artifact>
+ <excludes>
+ <exclude>META-INF/*.SF</exclude>
+ <exclude>META-INF/*.DSA</exclude>
+ <exclude>META-INF/*.RSA</exclude>
+ </excludes>
+ </filter>
+ </filters>
+ <transformers>
+ <transformer implementation=
+ "org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>com.powsybl.gse.demo.GseDemo</mainClass>
+ </transformer>
+ </transformers>
</configuration>
<executions>
<execution>
- <!-- required before build-native -->
- <id>create-jfxjar</id>
- <phase>package</phase>
- <goals>
- <goal>build-jar</goal>
- </goals>
- </execution>
- <execution>
- <id>create-native</id>
<phase>package</phase>
<goals>
- <goal>build-native</goal>
+ <goal>shade</goal>
</goals>
</execution>
</executions>
diff --git a/pom.xml b/pom.xml
index 7405fd0..03a6fb1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -71,7 +71,7 @@
<maven.compiler.version>3.8.0</maven.compiler.version>
<maven.deploy.version>2.8.2</maven.deploy.version>
<maven.enforcer.version>3.0.0-M2</maven.enforcer.version>
- <maven.javafx.version>8.8.3</maven.javafx.version>
+ <maven.shade.version>3.2.1</maven.shade.version>
<maven.gpg.version>1.6</maven.gpg.version>
<maven.install.version>2.5.2</maven.install.version>
<maven.jar.version>3.1.0</maven.jar.version> |
The splash screen is displayed when using the following command line
|
I ran jdeps on the shaded jar according to https://medium.com/azulsystems/using-jlink-to-build-java-runtimes-for-non-modular-applications-9568c5e70ef4
Stripping the modules subpackages, I created a runtime:
It's 105Mb. I also created a runtime with jlink through trial and error just by adding the modules of the missing classes at startup which gave:
It's 85Mb In both cases I ran the app by copying the uberjar to |
Tested on linux only. This shouldn't work on windows because the docs say " For Windows, you have to unzip the bundle in the same directory as the JDK, as the packager wrapper expect to find the java binary at the same level. " Maybe it will work in the future with a new release from http://download2.gluonhq.com/jpackager/11/jdk.packager-windows.zip In the meantime, users should be able to move the downloaded jpackager to their jdk themselves and invoke maven with the correct path to the packager with something like this (untested): mvn -Djpackager.path=C:\\Path\\To\\JDK\\bin\\jpackager
I implemented the native package with the infos from https://mail.openjdk.java.net/pipermail/openjfx-dev/2018-September/022500.html and https://github.com/skymatic/javafx11-test/ and tested it on my machine (fedora 27). |
- The bug where we have to list the jars manually has been fixed - We need to create a jdk11 runtime with jlink and pass it with --runtime to jpackage - It should work on windows without having to provide the path manually
…build failures without mvn clean This does not work when running mvn clean package because the profile is decided at the start..
…trying to detect it The previous approach would fail for `mvn clean package` because the profile is activated at the start of maven.
I have reimplemented this using https://jdk.java.net/jpackage/ . It's java13 early access jpackage. I used the current JAVA_HOME (e.g. java11) jlink to create a runtime image that is fed to jpackage, so the resulting native app has nothing to do with java13. The build also downloads jpackage (and the whole jdk, ~200Mbytes) but this is cached in M2_REPOSITORY/.cache by the download-maven-plugin. Note: download-maven-plugin 1.4.1 doesn't use the http configuration from settings.xml for https downloads, so pay attention to duplicate your proxy configuration in settings.xml if you have one. Using java13 early access jpackage was suggested here https://mail.openjdk.java.net/pipermail/openjfx-dev/2019-January/023055.html and here https://mail.openjdk.java.net/pipermail/openjfx-dev/2018-December/023003.html where the original provider for the backported jpackager said : |
I couldn't get it to work though, jpackager.exe --version-swap [..] was not doing anything on windows 2012 R2 (it is using BeginUpdateResource, UpdateResource and EndUpdateResource ms functions). But the config file does contain the following info in gse.properties: Comments= CompanyName=PowSyBl FileDescription=gse FileVersion=1.4.0-SNAPSHOT InternalName=gse.exe LegalCopyright=Copyright (C) 2019 LegalTrademarks= OriginalFilename=gse.exe PrivateBuild= ProductName=gse ProductVersion=1.4.0-SNAPSHOT SpecialBuild= But the exe file has: D:\Users\harperjon> get-command "D:\Users\harperjon\Downloads\all\powsybl-gse\gse-demo\target\native\gse\gse.exe" | format-list Name : gse.exe CommandType : Application Definition : D:\Users\harperjon\Downloads\all\powsybl-gse\gse-demo\target\native\gse\gse.exe Extension : .exe Path : D:\Users\harperjon\Downloads\all\powsybl-gse\gse-demo\target\native\gse\gse.exe FileVersionInfo : File: D:\Users\harperjon\Downloads\all\powsybl-gse\gse-demo\target\native\gse\gse.exe InternalName: jpackageapplauncher OriginalFilename: jpackageapplauncher.exe FileVersion: 13 FileDescription: OpenJDK Platform binary Product: OpenJDK Platform 13 ProductVersion: 13 Debug: False Patched: False PreRelease: False PrivateBuild: False SpecialBuild: False Language: Langue neutre The previous java8 implementation on windows 2012 R2 didn't work either: D:\Users\harperjon> get-command "D:\Users\harperjon\Downloads\all8\powsybl-gse\gse-demo\target\jfx\native\gse\gse.exe" | format-list Name : gse.exe CommandType : Application Definition : D:\Users\harperjon\Downloads\all8\powsybl-gse\gse-demo\target\jfx\native\gse\gse.exe Extension : .exe Path : D:\Users\harperjon\Downloads\all8\powsybl-gse\gse-demo\target\jfx\native\gse\gse.exe FileVersionInfo : File: D:\Users\harperjon\Downloads\all8\powsybl-gse\gse-demo\target\jfx\native\gse\gse.exe InternalName: OriginalFilename: FileVersion: FileDescription: Product: ProductVersion: Debug: False Patched: False PreRelease: False PrivateBuild: False SpecialBuild: False Language:
I tested that it works on windows. On linux, jpackage doesn't do anything with the icon for create-image. Untested on mac.
Apparently they have fixed the problem of not setting the versioninfo of the windows exe, but we need to wait jpackage EA4 to test it. https://mail.openjdk.java.net/pipermail/core-libs-dev/2019-February/058704.html |
|
Signed-off-by: Paul Bui-Quang <[email protected]>
Signed-off-by: Paul Bui-Quang <[email protected]>
No description provided.