ljacomet / logging-capabilities

Apache License 2.0
40 stars 6 forks source link

Error: Could not resolve org.slf4j:slf4j-api:1.7.30 #9

Closed xmlking closed 3 years ago

xmlking commented 4 years ago

I am applying slf4j-simple for all subprojects

loggingCapabilities {
    selectSlf4JBinding("org.slf4j:slf4j-simple:$slf4jVersion")
}

and overwriting in the specific subproject as needed

loggingCapabilities {
    selectSlf4JBinding("org.slf4j:slf4j-jdk14:$slf4jVersion")
}

for one of the subproject (greeting-quarkus) it is giving error, which I cannot figerout root cause: I already added required deps:

runtimeOnly("org.slf4j:slf4j-jdk14:$slf4jVersion")
runtimeOnly("org.slf4j:slf4j-simple:$slf4jVersion")

How to reproduce

git clone https://github.com/xmlking/micro-apps
gradle :apps:greeting-quarkus:quarkusBuild 

Error

gradle :apps:greeting-quarkus:quarkusBuild 

> Configure project :
Version: 1.6.5-SNAPSHOT,  Branch: develop, isCI: false
SpotlessChangelog Version Next: 1.7.0-SNAPSHOT  Last: 1.6.4

> Task :apps:greeting-quarkus:quarkusBuild FAILED
building quarkus runner

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':apps:greeting-quarkus:quarkusBuild'.
> Could not resolve all dependencies for configuration ':apps:greeting-quarkus:runtimeClasspath'.
   > Could not resolve org.slf4j:slf4j-api:1.7.30.
     Required by:
         project :apps:greeting-quarkus > io.quarkus:quarkus-universe-bom:1.4.2.Final
         project :apps:greeting-quarkus > io.quarkus:quarkus-smallrye-health:1.4.2.Final > io.quarkus:quarkus-core:1.4.2.Final
         project :apps:greeting-quarkus > org.slf4j:slf4j-simple:1.7.30
      > Multiple forces on different versions for virtual platform dev.jacomet.logging.align:slf4j
   > Could not resolve org.slf4j:slf4j-simple:1.7.25.
     Required by:
         project :apps:greeting-quarkus > io.quarkus:quarkus-universe-bom:1.4.2.Final
      > Multiple forces on different versions for virtual platform dev.jacomet.logging.align:slf4j

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
xmlking commented 4 years ago

I can workaround this issue by excluding logging-capabilities for the troubled subproject https://github.com/xmlking/micro-apps/blob/develop/build.gradle.kts#L169-L172 but I am looking for a real fix or root cause...

ljacomet commented 4 years ago

Thanks for your interest in this plugin.

There are multiple things at play here:

However there is an alignment bug in Quarkus. Their BOM declares the following:

...
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-api</artifactId>
  <version>1.7.30</version>
</dependency>
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>jcl-over-slf4j</artifactId>
  <version>1.7.30</version>
</dependency>
...
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-simple</artifactId>
  <version>1.7.25</version>
</dependency>
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-nop</artifactId>
  <version>1.7.25</version>
</dependency>
...

Which means that they enforce different versions of slf4j. And that issue shows up the moment logging-capabilities adds its platform declaration for alignment.

Unfortunately, the alignment feature cannot be turned off. I have reported the issue on the Quarkus side: quarkusio/quarkus#9715

So for now, you have to disable the plugin for Quarkus project unfortunately, unless you are ready to write a component metadata rule that would fix the Quarkus BOM on the fly when using it in your project.

If you are interested in that, I can give more specific pointers.

xmlking commented 4 years ago

your analysis is correct. when i add 1.7.30 to runtimeOnly, it asks for 1.7.25 , and if i add 1.7.25 it asks for 1.7.30 🥶 once quarkus fix it, i will use what ever is in their BOM for this subproject. your plugin really helped me in my monorepo, where i have to use JUL backend for apache beam projects and 2.0.0-alpha1 for rest of the projects. thank you for contributing this plugin

ljacomet commented 3 years ago

Closing as there is nothing that can be done in this project to fix this.