Adding a dependency for a buildSrc script

For one of my build scripts, I’ve abstracted a bunch of configuration into a plugin under buildSrc. That’s fine. I want to parse an XML file in that plugin and I’m trying to avoid the deprecated APIs, so I try to import groovy.xml.XmlSlurper in my plugin. That class can’t be resolved. Okay. So I tried to add org.codehaus.groovy:groovy-xml:3.0.9 to my buildscript. I expected this to work:

buildscript {
  repositories {
    mavenCentral()
    mavenLocal()
  }

  dependencies {
    classpath: 'org.codehaus.groovy:groovy-xml:3.0.9'
  }
}

But it doesn’t. I’ve tried half a dozen variations on that theme to no avail. I expect I’m overlooking something obvious. Can someone point out what it, please?

You can simply declare dependencies for the buildSrc directory in the dependencies block in the build.gradle[.kts] file in the buildSrc directory.

Thank you. I’ll give that a try. I did imagine it was something obvious!