How to get groovy-sql on classpath

The document Upgrading to Gradle 9.0.0 lists groovy-sql in the section “Removal of select Groovy modules from the Gradle distribution”. That section says that these classes “will no longer be available on the classpath”. Unfortunately, the document does not provide any guidance on what the workaround is or what the new/improved way of accessing a database is.

How am I supposed to migrate existing scripts that use classes groovy.sql.Sql and groovy.sql.GroovyRowResult to Gradle 9?

I have tried Googling for answers, but with no luck. Most pages I find suggest something similar to the code below. However, this does not work for me.

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.apache.groovy:groovy-sql:5.0.3'
}

Note that my existing scripts do not build anything or otherwise use any Gradle plugins. They are simply scripts that need to access a database and I happened to write them in Gradle.

Your snippet is almost correct, just that you try to add a dependency for what you would build. Wrap it in a buildscript { ... } block and use the configuration classpath instead of implementation to add to the buildscript classpath.