gesellix/docker-client

Update to groovy4

Opened this issue ยท 11 comments

We are currently migrating all our libs and services to groovy 4 and therefore would appreciate if you could update this library as well.

sgrell commented

We are using it directly a few times but mostly as the gradle-plugin.

The docker-client will be released soonish.
I still have to ensure that Gradle accepts Groovy 4, you can follow the issue at gesellix/gradle-docker-plugin#353

Gradle doesn't allow me to enforce Groovy 4 over the version bundled with Gradle. As mentioned at gradle/build-tool-roadmap#16 (comment) they plan to upgrade to Groovy 4 with Gradle 9.x.

I think I need to revert the Groovy 4 upgrade or I could try to publish the docker-client for both Groovy versions or I would have to get rid of Groovy.

So before going into implementation details I'd like to learn more about your use case. As long as the docker-client isn't used in a Gradle context, the Groovy version doesn't matter. Would a Groovy 3.x based docker-client used in a Gradle context block you from upgrading to Groovy 4?

As a side note/workaround: this snippet modifies Gradle's dependency resolution so that it uses Groovy 4 instead of Groovy 3 (well, not for Gradle plugins ๐Ÿ™„):

  configurations.all {
    resolutionStrategy {
      dependencySubstitution {
        all {
          requested.let {
            if (it is ModuleComponentSelector && it.group == "org.codehaus.groovy") {
              logger.lifecycle("substituting $it with 'org.apache.groovy:*:${groovyVersion}'")
              useTarget(
                  "org.apache.groovy:${it.module}:${groovyVersion}",
                  "Changed Maven coordinates since Groovy 4"
              )
            }
          }
        }
      }
    }
  }
sgrell commented

We understand the problem with the plugin that of course has to use the provided groovy version. We still don't really understand, why there is a version conflict with the newest pact version and the docker-client. However we reconfigured our build.gradle to resolve this dependency problem and now it works with the current version of the docker-client that is still on groovy3. So we are totally fine with a revert of the PR and you don't have to put in more work. Thank you.

If you like you can show me the conflict details, maybe I can configure the published dependency information in the docker-client so that the chance for dependency conflicts will be minimized in the future?

sgrell commented

We have a mutli-module setup and configured all the plugins that we use in the root-build.gradle, but we don't apply them yet, among others the docker-publish plugin and the pact-plugin:

plugins {
  alias(libs.plugins.dockerPublish) apply false
  alias(libs.plugins.pact) apply false
}

That results in the following conflicts:

> Could not resolve all files for configuration ':classpath'.
   > Could not resolve org.apache.groovy:groovy:4.0.11.
     Required by:
         project : > au.com.dius.pact:au.com.dius.pact.gradle.plugin:4.6.3 > au.com.dius.pact.provider:gradle:4.6.3
         project : > au.com.dius.pact:au.com.dius.pact.gradle.plugin:4.6.3 > au.com.dius.pact.provider:gradle:4.6.3 > au.com.dius.pact:provider:4.6.3
         project : > au.com.dius.pact:au.com.dius.pact.gradle.plugin:4.6.3 > au.com.dius.pact.provider:gradle:4.6.3 > au.com.dius.pact.core:model:4.6.3
         project : > au.com.dius.pact:au.com.dius.pact.gradle.plugin:4.6.3 > au.com.dius.pact.provider:gradle:4.6.3 > au.com.dius.pact:provider:4.6.3 > au.com.dius.pact.core:support:4.6.3
         project : > au.com.dius.pact:au.com.dius.pact.gradle.plugin:4.6.3 > au.com.dius.pact.provider:gradle:4.6.3 > au.com.dius.pact:provider:4.6.3 > au.com.dius.pact.core:matchers:4.6.3
         project : > au.com.dius.pact:au.com.dius.pact.gradle.plugin:4.6.3 > au.com.dius.pact.provider:gradle:4.6.3 > au.com.dius.pact:provider:4.6.3 > au.com.dius.pact.core:pactbroker:4.6.3
         project : > au.com.dius.pact:au.com.dius.pact.gradle.plugin:4.6.3 > au.com.dius.pact.provider:gradle:4.6.3 > org.apache.groovy:groovy:4.0.11 > org.apache.groovy:groovy-bom:4.0.11
      > Module 'org.apache.groovy:groovy' has been rejected:
           Cannot select module with conflict on capability 'org.codehaus.groovy:groovy:4.0.11' also provided by [org.codehaus.groovy:groovy:3.0.19(runtime)]
   > Could not resolve org.apache.groovy:groovy.
     Required by:
         project : > au.com.dius.pact:au.com.dius.pact.gradle.plugin:4.6.3 > au.com.dius.pact.provider:gradle:4.6.3 > au.com.dius.pact:provider:4.6.3
      > Module 'org.apache.groovy:groovy' has been rejected:
           Cannot select module with conflict on capability 'org.codehaus.groovy:groovy:4.0.11' also provided by [org.codehaus.groovy:groovy:3.0.19(runtime)]
   > Could not resolve org.codehaus.groovy:groovy:3.0.19.
     Required by:
         project : > de.europace.docker-publish:de.europace.docker-publish.gradle.plugin:2.0.1 > de.europace.gradle:docker-publish-gradle-plugin:2.0.1 > de.gesellix:gradle-docker-plugin:2023-10-04T09-45-00 > de.gesellix:docker-client:2023-10-03T23-05-00
         project : > de.europace.docker-publish:de.europace.docker-publish.gradle.plugin:2.0.1 > de.europace.gradle:docker-publish-gradle-plugin:2.0.1 > de.gesellix:gradle-docker-plugin:2023-10-04T09-45-00 > de.gesellix:docker-client:2023-10-03T23-05-00 > org.codehaus.groovy:groovy-json:3.0.19
      > Module 'org.codehaus.groovy:groovy' has been rejected:
           Cannot select module with conflict on capability 'org.codehaus.groovy:groovy:3.0.19' also provided by [org.apache.groovy:groovy:4.0.11(groovyRuntimeElements)]
   > Could not resolve org.codehaus.groovy:groovy:{strictly [3,); prefer 3.0.19}.
     Required by:
         project : > de.europace.docker-publish:de.europace.docker-publish.gradle.plugin:2.0.1 > de.europace.gradle:docker-publish-gradle-plugin:2.0.1 > de.gesellix:gradle-docker-plugin:2023-10-04T09-45-00 > de.gesellix:docker-client:2023-10-03T23-05-00
      > Module 'org.codehaus.groovy:groovy' has been rejected:
           Cannot select module with conflict on capability 'org.codehaus.groovy:groovy:3.0.19' also provided by [org.apache.groovy:groovy:4.0.11(groovyRuntimeElements)]

Our fix was then actually very simple, we removed the pact-plugin from this configuration and directly included it in the module where we use it, in this module we don't publish anything with docker, so there is no conflict on that level.

However we still don't really understand what is causing the problem because as far as we can see pact also uses the internal gradle groovy version.

I also can't see anything obvious, but there might be something in the .module metadata of the transitive dependencies about Groovy 4.
Do you have any dependency enforcments on Groovy in your build? Asking more specifically: is there any chance of enforcement for org.codehaus.groovy:*:4.x, meaning the combination of the groupId for Groovy 3, but the version for Groovy 4?

In other news: the docker-client is available in both variants (Groovy 3 and Groovy 4) now. You can use the usual dependency declaration and add the suffix -groovy-4 if you prefer Groovy 4. Example:

  • for Groovy 3: de.gesellix:docker-client:2023-10-18T22-40-00
  • for Groovy 4: de.gesellix:docker-client:2023-10-18T22-40-00-groovy-4
sgrell commented

Thanks for supporting both groovy versions ๐Ÿ˜„

We removed any depencency enforcement on org.codehaus.groovy and replaced them with org.apache.groovy, so no this weird combination should not exist. I also double checked the dependencies and they don't include any old groovy version.

I guess this issue is done, right?