Use Groovy version 3 in build script

Hi, I am trying to use a class that is only available in Groovy version 3 and up in my build scripts. Is there a way to get Gradle to use Groovy version 3?

I tried this already:

buildscript {
  repositories {
  dependencies {
    classpath ‘org.codehaus.groovy:groovy-all:3.0.3’

Thanks, Thomas