2021年2月6日星期六

jlink packages current platform's binaries

I am trying to build cross-platform archives of an application built using Java 11 and packaged with jlink.

For the cross-platform packaging I am basing my build on this answer. I have managed to make my Gradle build download the target platform's JDK and invoke jlink with the appropriate jmods folder, however the target image always includes the binaries and JRE structure of the host platform (in my case Windows, meaning the generated bin folder always includes DLLs and Windows executables). If I supply the --strip-native-commands flag then no executables are included at all, although the DLLs still are.

Is there any way to make jlink package the correct JRE files?

Host JDK: Windows Oracle JDK 11.0.10 x64

Target JDK: OpenJDK 11.0.2 x64

Sample Linux invocation:

C:\Program Files\Java\jdk-11.0.10/bin/jlink.exe    --module-path C:\projectdir\build\install\project-linux\lib;C:\projectdir\build\JREs\linux\jmods    --add-modules com.acme.app    --compress 2    --launcher app=com.acme.app/com.acme.app.Main    --no-header-files    --no-man-pages    --strip-debug    --dedup-legal-notices=error-if-not-same-content    --output C:\projectdir\build\packageFiles\linux  

GraalVM

Using GraalVM CE Java 11 21.0.0 yields:

java.io.IOException: Invalid JMOD file: C:\jdks\graalvm-ce-java11-21.0.0\jmods\java.base.jmod  

Which makes it seem like GraalVM's jlink always attempts to use the host's JMOD files.

OpenJDK

Using OpenJDK 11.0.2 x64 yields the same result of including the host's binary files in the created runtime image. The same behaviour is true for Zulu OpenJDK 11.0.10+9 x64.

https://stackoverflow.com/questions/66083431/jlink-packages-current-platforms-binaries February 07, 2021 at 08:33AM

没有评论:

发表评论