sbt-native-packager
sbt-native-packager copied to clipboard
Simplifly dealing with jdeps in JlinkPlugin
This was discussed in passing in a few other issues, but I'd rather have one place to track it.
- We feed our whole classpath to
jdepsto find which platform modules we need.jdeps, however, requires the modules to form a coherent dependency graph with no missing dependencies. This was the reason for #1293. More recently, I've had a similar thing happen because HikariCP added a module descriptor thatrequires a lot of dependencies it doesn't bring in through its POM, which makesjdepsfail like this:
Note that this can't be dealt with using$ jdeps -R --multi-release 11 HikariCP-3.4.5.jar Exception in thread "main" java.lang.module.FindException: Module micrometer.core not found, required by com.zaxxer.hikari at java.base/java.lang.module.Resolver.findFail(Resolver.java:877) at java.base/java.lang.module.Resolver.resolve(Resolver.java:191) at java.base/java.lang.module.Resolver.resolve(Resolver.java:140) at java.base/java.lang.module.Configuration.resolve(Configuration.java:422) at java.base/java.lang.module.Configuration.resolve(Configuration.java:256) at jdk.jdeps/com.sun.tools.jdeps.JdepsConfiguration.<init>(JdepsConfiguration.java:117) at jdk.jdeps/com.sun.tools.jdeps.JdepsConfiguration$Builder.build(JdepsConfiguration.java:563) at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.buildConfig(JdepsTask.java:589) at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:543) at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:519) at jdk.jdeps/com.sun.tools.jdeps.Main.main(Main.java:49)jlinkIgnoreMissingDependencies! There are other workarounds (e.g. micromanagingjlinkBuildImage / fullClassPath), but using those is annoying, it subtly breaksjlinkModules, and it doesn't have anything to do with building an image. jlinkIgnoreMissingDependenciesis annoying. It's a remnant of the first iteration ofJlinkPlugin, before we restricted it to only platform modules (#1248), and I didn't find much use for it so far except for finding missing Jakarta API dependencies. I think this dependency check should be restricted to platform modules/packages only.
Here's a helper plugin I've hacked together to simplify dealing with this stuff: https://gist.github.com/nigredo-tori/3b168da8e3cdcc7766ace3f23e999ec5 . These tweaks can't be adopted into this project as they are - mostly because they use Java 11 - but it should hopefully be useful as a starting point for solving the issues above.