Description
I'm submitting a…
- bug report
- feature request
- other
Short description of the issue/suggestion:
I have a special setup where I include my own compiled 'javafx-graphics-22-win.jar' because I compiled it with enabling the OpenGL rendering pipeline. My own javafx graphics lib is called 'javafx.graphics..jar' which is in my libs folder of my project and it gets imported like this
implementation fileTree(include: ["*.jar"], dir: "libs")
This is my javapackager task
tasks.register('packageApplication', PackageTask) {
// mandatory
mainClass = 'com.grill.app.Launcher'
// optional
bundleJre = true
generateInstaller = true
administratorRequired = false
copyDependencies = true
vmArgs = [
'--module-path=libs',
'--add-modules=javafx.graphics,javafx.controls,javafx.fxml,javafx.base,javafx.web',
'--add-opens=javafx.base/com.sun.javafx=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.prism=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.prism.ps=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.prism.shader=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.prism.impl=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.scenario.effect.impl=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.scenario.effect.impl.prism=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.prism.impl.ps=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.glass.utils=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.glass.ui=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.prism.es2=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.javafx.geom.transform=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.prism.paint=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.javafx.scene.layout=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED',
'--add-opens=javafx.graphics/javafx.scene.image=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.javafx.util=ALL-UNNAMED',
'--add-opens=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED',
'--add-opens=javafx.base/com.sun.javafx.logging=ALL-UNNAMED',
'-Dprism.forceGPU=true',
'-XX:+UseZGC',
'-XX:+ZGenerational'
]
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
vmArgs.add('--add-opens=javafx.graphics/com.sun.prism.d3d=ALL-UNNAMED')
winConfig {
headerType = HeaderType.gui
icoFile = file('src/main/resources/com/grill/app/image/icon.ico')
}
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
linuxConfig {
pngFile = file('src/main/resources/com/grill/app/image/icon_256.png')
}
}
}
Because of this I have now dublicated graphics jar files in my generated libs folder of javapackager and I get following error when I try to start the application
Error occurred during initialization of boot layer
java.lang.module.FindException: Two versions of module javafx.graphics found in libs (javafx.graphics.jar and javafx-graphics-22-win.jar)
So in order to mitigate this issue I have another task which deleted the other unwanted graphics jar
tasks.register('deleteNativePackages', Delete) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
delete fileTree(dir: file("$buildDir/App/libs"), include: '**/javafx-graphics-*.jar')
}
doLast {
logger.lifecycle "Deleted unwanted javafx jars in the build folder."
}
}
packageApplication.finalizedBy deleteNativePackages
This works for the generated exe in the folder but is already too late for the installer, which means my installers will get generated with the additional graphics jar bundled. This leads to the same crash as mentioned above when executing my installed application on a PC (because it bundles the two graphics jar libs).
I tried to name the graphics jar the same as the original (javafx-graphics-22-win.jar
) but this leads to following error
- What went wrong:
Execution failed for task ':packageApplication'.
Entry javafx-graphics-22-win.jar is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/8.5/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.
Not sure why I get this erros as I have defined these rules which are working in other tasks
tasks.configureEach {
if (it instanceof Copy || it instanceof Zip || it instanceof Tar) {
it.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
Steps to reproduce the issue/enhancement:
- [First Step] include a second javafx graphics module for example in your libs folder and include it into your project
- [Second Step] Define a basic javapackager task
- [Other Steps...] execute the javapackager task and with copyDependencies and try to execute the compiled exe and the installer.
What is the expected behavior?
Would be nice if there is a way to handle such a scenario in JavaPackager, but maybe there is or maybe there is a workaround for that? Maybe a hook to a task which allows you to do certain things before the installer gets created?
What is the current behavior?
I think there is no easy way to handle that scenario with javapackager but I might be wrong?
Please tell us about your environment:
- JavaPackager version: v1.7.5
- OS version: Windows 11
- JDK version: JDK 21
- Build tool:
- Maven
- Gradle