Not directly a Gradle issue I think, but I will try to see if anyone here can assist.
The project I am building was a Java 1.8 Swing application, that I now am trying to build and package with Java 11.
This works fine on Linux, but fails on Windows
Using AdoptOpenJDK on Windows, while Linux I am using OpenJDK from SUSE Open Build Service.
My gradle task to create a java runtime with jlink.
task createRuntime(type: Exec) {
doFirst {
delete "$buildDir/runtime"
}
commandLine 'jlink',
'--add-modules', 'java.base,java.desktop,java.logging,java.scripting,java.xml.bind',
'--bind-services',
'--no-header-files',
'--no-man-pages',
'--compress=2',
'--strip-debug',
'--output', "$buildDir/runtime"
}
The error message I get on Windows.
> Task :createRuntime
Task ':createRuntime' is not up-to-date because:
Task has not declared any outputs despite executing actions.
Custom actions are attached to task ':createRuntime'.
Starting process 'command 'jlink''. Working directory: C:\cygwin64\home\build\workspace\mcs-gui Command: jlink --add-modules java.base,java.desktop,java.logging,java.scripting,java.xml.bind --bind-services --no-header-files --no-man-pages --compress=2 --strip-debug --output C:\cygwin64\home\build\workspace\mcs-gui\build/runtime
Successfully started process 'command 'jlink''
Error: Module java.xml.bind not found
But JAXB dependencies are on the “classpath”
The project is not a modularized Java project. Not sure why it works on Linux, but not Windows.
dependencies {
compile(group: 'no.spacetec', name: 'meos-mc-protobuf-java', version: '1.4.25')
compile(group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0')
compile(group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0')
compile(group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.0')
compile(group: 'javax.activation', name: 'activation', version: '1.1.1')
compile(group: 'com.google.code.gson', name: 'gson', version: '2.8.0')
compile(group: 'jsattrak', name: 'jsattrak', version: '4.1.10')
compile(group: 'com.miglayout', name: 'miglayout-swing', version: '5.0')
compile(group: 'org.jfree', name: 'jfreechart', version:'1.0.19') {
exclude(module: 'itext')
exclude(module: 'xml-apis')
}
testCompile(group: 'junit', name: 'junit', version: '4.12')
}
The gradle installDist that createPackage depends on has the JAXB dependencies which I have added to jlink --add-modules java.xml.bind. I wonder if this is the cause, it cannot find the JAXB, but then Why does this work fine on Linux. This works on Windows if I remove java.xml.bind from --add-modules.
I do not think I really need java.xml.bind in the created Java runtime. It is provided as a dependency in the installDist task.