Kelvin Chung
01/18/2025, 7:32 PMjvmDependencyConflicts {
logging {
selectJCLImplementation("org.slf4j:jcl-over-slf4j")
}
}
I'm encountering an error where a dependency that I want to add is being rejected:
> Could not resolve org.springframework:spring-jcl:5.3.36.
Required by:
project :<redacted> > com.atlassian.jira:jira-rest-java-client-core:6.0.1 > org.springframework:spring-beans:5.3.36 > org.springframework:spring-core:5.3.36
> Module 'org.springframework:spring-jcl' has been rejected:
Cannot select module with conflict on capability 'org.gradlex:commons-logging-impl:1.0' also provided by [commons-logging:commons-logging:1.2(runtime)]
> Could not resolve commons-logging:commons-logging:1.2.
Required by:
project :<redacted> > com.atlassian.jira:jira-rest-java-client-core:6.0.1 > com.atlassian.httpclient:atlassian-httpclient-library:4.0.1 > org.apache.httpcomponents:httpclient-cache:4.5.14
project :<redacted> > com.atlassian.jira:jira-rest-java-client-core:6.0.1 > com.atlassian.httpclient:atlassian-httpclient-library:4.0.1 > org.apache.httpcomponents:httpasyncclient:4.1.5
project :<redacted> > com.atlassian.jira:jira-rest-java-client-core:6.0.1 > com.atlassian.httpclient:atlassian-httpclient-library:4.0.1 > org.apache.httpcomponents:httpclient-cache:4.5.14 > org.apache.httpcomponents:httpclient:4.5.14
> Module 'commons-logging:commons-logging' has been rejected:
Cannot select module with conflict on capability 'org.gradlex:commons-logging-impl:1.0' also provided by [org.springframework:spring-jcl:5.3.36(runtimeElements)]
This looks like it makes sense on paper, since spring-jcl is said to be able to auto-switch between multiple logging providers. Is there some additional configuration that needs to be done wrt the plugin?Jendrik Johannes
01/18/2025, 9:12 PMorg.slf4j:jcl-over-slf4j
on your classpath. In that case, it is not selected, because it is not part of the conflict. The plugin, as of now, never adds dependencies, just resolves conflicts. (Which can be a confusing behavior.)
In your case you have spring-jcl
and commons-logging:commons-logging
in conflict (but no jcl-over-slf4j
)
Can you somehow configure your build to always add the org.slf4j:jcl-over-slf4j
dependency? That is one way to solve the issue.
(There is also a chance that you hit a Gradle bug, as there are some issues in this area if the dependency Graph is complex. Which Gradle version are you using? There have been improvements in 8.11 and 8.12)Kelvin Chung
01/18/2025, 9:16 PMenforceSlf4JSimple()
, but that appears to be trying to squish a fly with a sledgehammer. Or at least, confirms the fact that jcl-over-slf4j isn't in the classpath.
Still, given that I'm developing a Gradle plugin, and Gradle's use of slf4j, that there would be some recommended setting.Jendrik Johannes
01/18/2025, 9:22 PMenforceSlf4JSimple()
does not really sound correct. Although it might give the desired result. I am not sure myself.
I think adding the org.slf4j:jcl-over-slf4j
dependency would be the right thing to do.Vampire
01/19/2025, 9:34 PMVampire
01/19/2025, 9:35 PM~/.gradle/wrapper/dists/gradle-8.10.1-bin/e90i968nv55tch01zkse4avv3/gradle-8.10.1/lib/jcl-over-slf4j-1.7.36.jar
exists. So I think you don't need to do anything at all to make the logging go to the normal Gradle logging system.Jendrik Johannes
01/20/2025, 10:11 AMVampire
01/20/2025, 12:34 PMenforceGradle()
that then suppresses things replaced by parent Gradle class loader or already having a bridge 😄