I decided to try the Badass Jlink Plugin, see if that could solve my problem I am having with running JLink in Windows with an additional module path.
I have been using a simple Exec task to run jlink to create a runtime image. I use this runtime image as input to jpackage --runtime-image.
The plugin offers little to no help to create a runtime image for Non-Modular projects.
I just want a plain simple runtime image, with additional modules provided with --module-path and --add-modules.
I cannot get the Jlink plugin to leave my application alone when creating the runtime image. It complains about JavaFX and java.xml.bind. The java.xml.bind is declared as dependencies, and I do not need it in the runtime image. For the JavaFX I have the jmods which I want to add using --add-modules (which the plugin does not have any flag for).
This is my jlink Exec task. It just creates a runtime image I later can use with jpackage to create a native installer. As I said my application is not modular.
task createRuntime(type: Exec) {
def outputDir = file("${buildDir}/runtime")
outputs.dir(outputDir)
doFirst {
delete outputDir
}
executable = "jlink"
args = [
'--module-path', '/usr/java/javafx-jmods-11',
'--add-modules', 'java.base,java.sql,java.desktop,java.logging,java.scripting,javafx.base,javafx.controls,javafx.graphics,javafx.fxml,javafx.media,javafx.web,javafx.swing',
'--bind-services',
'--no-header-files',
'--no-man-pages',
'--compress=2',
'--strip-debug',
'--output', outputDir.path
]
}
My attempt to using the Badass JLink Plugin:
jlink {
def outputDir = file("${buildDir}/runtime")
imageDir = outputDir
options = [ '--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages' ]
addExtraModulePath("/usr/java/javafx-jmods-11")
customImage {
jdkModules = [
'java.base', 'java.sql', 'java.desktop', 'java.logging', 'java.scripting',
'javafx.base', 'javafx.controls', 'javafx.graphics', 'javafx.fxml',
'javafx.media', 'javafx.web', 'javafx.swing'
]
}
}
It complains about duplicate modules and modules not found. It seems JLink plugin is running javac on a custom created module-info.java.
error: duplicate module on application module path
module in javafx.graphics
error: module not found: javafx.swing
error: module not found: java.xml.bind
It looks more and more like the Badass JLink plugin is mostly only for modular application, even though there are hints it should work with non-modular projects.