Closed tivrfoa closed 2 years ago
Thanks for this suggestion, I have access to Linux, MacOS, Windows build machines so will try it out!
Hi @tivrfoa I've been working on this and I can get a linux shaded jar containing only OpenJFX linux native binaries (.so) but the mac jar contains mac+linux native binaries (.dylib and .so) and the win jar contains win+linux native binaries (.dll and .so).
My OpenJFX pom section looks like
<profile>
<id>with_openjfx_from_maven_central</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${openjfx.version}</version>
<classifier>${openjfx.native.os}</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>${openjfx.version}</version>
<classifier>${openjfx.native.os}</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>${openjfx.version}</version>
<classifier>${openjfx.native.os}</classifier>
</dependency>
</dependencies>
where the OS is passed on the command line with -D:
<properties>
<openjfx.version>17.0.0.1</openjfx.version>
<!--set on command line with -Dopenjfx.native.os={linux|win|mac} -->
<openjfx.native.os>linux</openjfx.native.os>
</properties>
Going to reach out to the OpenJFX experts on this one!
When I create the package using
mvn -Dopenjfx.native.os=win clean package
I get this in the log:
[INFO] --- maven-shade-plugin:3.2.0:shade (default) @ jitwatch-ui ---
[INFO] Including com.chrisnewland:jitwatch-core:jar:1.4.1 in the shaded jar.
[INFO] Including org.slf4j:slf4j-api:jar:1.7.30 in the shaded jar.
[INFO] Including ch.qos.logback:logback-classic:jar:1.2.3 in the shaded jar.
[INFO] Including ch.qos.logback:logback-core:jar:1.2.3 in the shaded jar.
[INFO] Including org.openjfx:javafx-controls:jar:win:17.0.0.1 in the shaded jar.
[INFO] Including org.openjfx:javafx-controls:jar:linux:17.0.0.1 in the shaded jar.
[INFO] Including org.openjfx:javafx-graphics:jar:17.0.0.1 in the shaded jar.
[INFO] Including org.openjfx:javafx-graphics:jar:linux:17.0.0.1 in the shaded jar.
[INFO] Including org.openjfx:javafx-base:jar:17.0.0.1 in the shaded jar.
[INFO] Including org.openjfx:javafx-base:jar:linux:17.0.0.1 in the shaded jar.
[INFO] Including org.openjfx:javafx-web:jar:win:17.0.0.1 in the shaded jar.
[INFO] Including org.openjfx:javafx-web:jar:linux:17.0.0.1 in the shaded jar.
[INFO] Including org.openjfx:javafx-controls:jar:17.0.0.1 in the shaded jar.
[INFO] Including org.openjfx:javafx-media:jar:17.0.0.1 in the shaded jar.
[INFO] Including org.openjfx:javafx-media:jar:linux:17.0.0.1 in the shaded jar.
[INFO] Including org.openjfx:javafx-swing:jar:win:17.0.0.1 in the shaded jar.
[INFO] Including org.openjfx:javafx-swing:jar:linux:17.0.0.1 in the shaded jar.
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] javafx-web-17.0.0.1-linux.jar, javafx-web-17.0.0.1-win.jar define 454 overlapping classes:
[WARNING] - javafx.scene.web.WebHistory
[WARNING] - com.sun.webkit.dom.HTMLTableCellElementImpl
[WARNING] - com.sun.webkit.Disposer$WeakDisposerRecord
[WARNING] - com.sun.javafx.fxml.builder.web.JavaFXWebViewBuilder
[WARNING] - com.sun.javafx.webkit.prism.WCRadialGradient
[WARNING] - com.sun.javafx.webkit.prism.WCGraphicsPrismContext$17
[WARNING] - com.sun.javafx.webkit.prism.WCGraphicsPrismContext$Type
[WARNING] - com.sun.webkit.dom.EntityImpl
[WARNING] - com.sun.webkit.dom.DOMSelectionImpl$SelfDisposer
[WARNING] - com.sun.webkit.graphics.WCPathIterator
[WARNING] - 444 more...
[WARNING] javafx-controls-17.0.0.1-win.jar, javafx-controls-17.0.0.1-linux.jar define 1212 overlapping classes:
[WARNING] - com.sun.javafx.scene.control.TableColumnBaseHelper$TableColumnBaseAccessor
[WARNING] - javafx.scene.control.ComboBoxBase
[WARNING] - javafx.scene.control.skin.ColorPickerSkin$StyleableProperties$2
[WARNING] - com.sun.javafx.scene.control.inputmap.InputMap$KeyMappingInterceptor
[WARNING] - javafx.scene.control.cell.ChoiceBoxTreeTableCell
[WARNING] - javafx.scene.control.TableCell$3
[WARNING] - javafx.scene.control.skin.ProgressBarSkin$StyleableProperties$1
[WARNING] - javafx.scene.control.DialogPane$2
[WARNING] - javafx.scene.control.skin.ToolBarSkin$4
[WARNING] - javafx.scene.control.skin.ColorPickerSkin$3
[WARNING] - 1202 more...
[WARNING] javafx-swing-17.0.0.1-linux.jar, javafx-swing-17.0.0.1-win.jar define 51 overlapping classes:
[WARNING] - javafx.embed.swing.SwingNode$PostEventAction
[WARNING] - com.sun.javafx.embed.swing.SwingDnD$3
[WARNING] - com.sun.javafx.embed.swing.SwingDnD$DnDTransferable
[WARNING] - com.sun.javafx.embed.swing.newimpl.FXDnDInteropN$FXDragGestureRecognizer
[WARNING] - javafx.embed.swing.SwingNode$1
[WARNING] - com.sun.javafx.embed.swing.newimpl.FXDnDInteropN$ComponentMapper
[WARNING] - javafx.embed.swing.InputMethodSupport
[WARNING] - com.sun.javafx.embed.swing.DataFlavorUtils$ByteBufferInputStream
[WARNING] - com.sun.javafx.embed.swing.newimpl.SwingNodeInteropN
[WARNING] - com.sun.javafx.embed.swing.FXDnD$1
[WARNING] - 41 more...
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
[WARNING] See http://maven.apache.org/plugins/maven-shade-plugin/
The solution was -Djavafx.platform=
Fix #339
Ideally we could conditionally set a Maven property depending on the operating system, then we could use it in the classifier, eg:
But I don't know how to do this in Maven.
I tested only on Linux.