I'm having trouble configuring the GradleX Depende...
# community-support
k
I'm having trouble configuring the GradleX Dependency Conflict Resolution plugin. My project is building a Gradle plugin, so I would think it would be natural to have a configuration like this:
Copy code
jvmDependencyConflicts {
  logging {
    selectJCLImplementation("org.slf4j:jcl-over-slf4j")
  }
}
I'm encountering an error where a dependency that I want to add is being rejected:
Copy code
> 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?
j
This is likely one of the tricky situations that are not yet solved well. We (team behind the plugin) have been discussing this again recently. This is the related issue I think, but it goes into all kinds of directions. We have to re-evalaute this more clearly. In short, I assume that you do not have
org.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)
k
Using Gradle 8.10.1. I did find that I could get past the error by using
enforceSlf4JSimple()
, 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.
j
For a Gradle plugin,
enforceSlf4JSimple()
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.
👍 1
v
Doesn't Gradle already include bridges for the usual suspects in logging and it would just work?
Yes, it does,
~/.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.
j
Thanks for clarifying @Vampire. I think some features of the Dependency Conflict Resolution plugin do not make much sense in Gradle plugin development. Things that are packaged in Gradle are not considered by the plugin.
v
Yep, you should add some
enforceGradle()
that then suppresses things replaced by parent Gradle class loader or already having a bridge 😄