Closed wkgcass closed 1 year ago
Because vertx doesn't have an explicit dependency on slf4j, you have to add addExtraDependencies 'slf4j'
to the jlink
block. Then you can add requires org.slf4j
to the mergedModule
block (the next version won't need this last step).
Fixed in v3.0.0. Now just add addExtraDependencies 'slf4j'
to the jlink
block.
I came across this problem when I was calling vertx's
TrustOptions.wrap(...)
method. I made a simple demo project to reproduce this error, I will attach it into this issue.vertx-slf4j-cannot-pass-jlink-demo.tar.gz
The demo is very simple, here's some critical code:
build.gradle
module-info.java
Main.java
my results
when I run
./gradlew clean run
, I get the following output:when I run
./gradlew clean jlink && ./build/image/bin/demo
, I get the following output:My demo main class can use slf4j, but the library (in merged module) cannot use it.
If I manually add
requires org.slf4j
inmergedModule { ... }
, it cannot even complete thejlink
task, an error will be thrown byjavac
: cannot find moduleorg.slf4j
.I'm not familiar with jlink plugin, but I tried to do some debugging.
In the generated ModuleManager.java here, it only reads
/module-info.class
in a jar file, but forslf4j
, its/module-info.class
is inMETA-INF/versions/9/module-info.class
I don't know whether this is related, but I post it here anyway.Downgrading to a non-modular slf4j version can solve the problem, but I believe the modular version should always be preferred in the future.