Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to groovy4 #578

Closed
huehnerlady opened this issue Oct 11, 2023 · 12 comments · Fixed by #579
Closed

Update to groovy4 #578

huehnerlady opened this issue Oct 11, 2023 · 12 comments · Fixed by #579

Comments

@huehnerlady
Copy link

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
Copy link
Contributor

sgrell commented Oct 11, 2023

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

@gesellix
Copy link
Owner

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

@gesellix gesellix reopened this Oct 13, 2023
@gesellix
Copy link
Owner

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?

@gesellix
Copy link
Owner

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
Copy link
Contributor

sgrell commented Oct 16, 2023

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.

@gesellix
Copy link
Owner

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?

gesellix added a commit that referenced this issue Oct 16, 2023
We still have to support Gradle < 9.x, which requires Groovy 3.x

See #578
gesellix added a commit that referenced this issue Oct 16, 2023
We still have to support Gradle < 9.x, which requires Groovy 3.x

See #578
@sgrell
Copy link
Contributor

sgrell commented Oct 17, 2023

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.

@gesellix
Copy link
Owner

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?

@gesellix
Copy link
Owner

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
Copy link
Contributor

sgrell commented Oct 19, 2023

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.

@huehnerlady
Copy link
Author

I guess this issue is done, right?

@gesellix
Copy link
Owner

Yes, I think so. Let's see what happens when Gradle 9 is released :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants