Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Gradle cannot find org.codehaus.groovy:groovy for a Groovy 4 version

ErrorCould not find org.codehaus.groovy:groovy:4.0.12.

Short answer

Groovy 4 and newer are published under the group org.apache.groovy. Only Groovy 1.x to 3.x use org.codehaus.groovy, so a 4.x version under the old group does not exist. Change the group in the dependency. If it still fails, the build has no repository that hosts Groovy, so add mavenCentral().

  • Applies to Gradle 8.x and 9.x, Groovy 4.0 and newer, Spock
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find where the old group is declared. It is often in a Spock or test dependency, or in a version catalog.

    grep -rn 'org.codehaus.groovy' build.gradle* */build.gradle* gradle/libs.versions.toml
  2. 2Match what you see, then jump to its fix

    1. 1The error names org.codehaus.groovy with a 4.x versionThe dependency still uses the old group idFix
    2. 2The same error for a library that is on Maven Central, in a project with no repositories blockNo repository in the build can serve the artifactFix

What does the error look like?

  • Could not find org.codehaus.groovy:groovy:4.0.12.

Cause 1 of 2

The dependency still uses the old group id

1Check

The Groovy download page gives org.apache.groovy:groovy:x.y.z for Groovy 4 and says older 1.x to 3.x versions use org.codehaus.groovy.

grep -rn 'groovy' build.gradle* gradle/libs.versions.toml

2Fix

Change the group and keep the version. Other Groovy modules use the same new group.

dependencies {
    testImplementation 'org.apache.groovy:groovy:4.0.12'
}

3Verify

Resolve the test classpath.

./gradlew dependencies --configuration testRuntimeClasspath

Confirmed by groovy.apache.org

Did this fix it?

Cause 2 of 2

No repository in the build can serve the artifact

1Check

A project with no repositories block, or only a private mirror, cannot resolve public libraries.

grep -rn -A4 'repositories' build.gradle* settings.gradle*

2Fix

Add Maven Central, either in the project or once in settings.gradle.

repositories {
    mavenCentral()
}

3Verify

Run the resolution again. The artifact downloads.

./gradlew dependencies --configuration testRuntimeClasspath

Confirmed by kotlinlang.org

Did this fix it?

How do I stop it coming back?

  • Keep Groovy versions in one version catalog entry, so the group is changed in one place.
  • When raising Spock or Groovy to a new major version, read its release notes for coordinate changes.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

Gradle runs no Cucumber scenarios from my feature files

Feature files exist under src/test but nothing runs

Cucumber runs on the JUnit Platform, so Gradle must call useJUnitPlatform() and have the cucumber-junit-platform-engine on the test classpath.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.