Gradle cannot find org.codehaus.groovy:groovy for a Groovy 4 version
Could 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().
Fix it fast
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.toml2Match what you see, then jump to its fix
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.toml2Fix
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 testRuntimeClasspathConfirmed by groovy.apache.org
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 testRuntimeClasspathConfirmed by kotlinlang.org
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
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack 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 fixBack end
A Gradle build fails on classes that use Lombok annotations
Error: Annotation processors must be explicitly declared now.
Lombok is two things for Gradle: a compile-time library and an annotation processor.
3 causes, each with a fixBack end
Gradle cannot calculate the javaCompiler for compileJava
Failed to calculate the value of task ':compileJava' property 'javaCompiler'
The build asks for a Java toolchain version that Gradle cannot find on the machine.
2 causes, each with a fixBack end
A JaCoCo report setting that worked in Gradle 7 fails in Gradle 8
Report property destination no longer exists after the Gradle 8 upgrade
Gradle 8.0 removed the enabled and destination properties of report objects.
2 causes, each with a fixBack end
Gradle 8 fails on Report destination: switch to outputLocation
What went wrong: 'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'
Gradle 8.0 removed the deprecated destination and enabled properties of the Report type.
2 causes, each with a fix