# Adding a dependency for a buildSrc script

**URL:** <https://discuss.gradle.org/t/adding-a-dependency-for-a-buildsrc-script/41070>\
**Category:** Help/Discuss\
**Created:** [September 27, 2021, 10:20am UTC](https://discuss.gradle.org/t/adding-a-dependency-for-a-buildsrc-script/41070 "2021-09-27T10:20:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Norm](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/norm/32/1096_2.png) [@Norm](https://discuss.gradle.org/u/Norm)\
**Post date:** [September 27, 2021, 10:20am UTC](https://discuss.gradle.org/t/adding-a-dependency-for-a-buildsrc-script/41070/1 "2021-09-27T10:20:48Z")

</div>

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:

```gradle
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?

---

<div class="post-metadata">

**Author:** ![StefMa](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/stefma/32/9384_2.png) [@StefMa](https://discuss.gradle.org/u/StefMa)\
**Post date:** [September 30, 2021, 6:43pm UTC](https://discuss.gradle.org/t/adding-a-dependency-for-a-buildsrc-script/41070/2 "2021-09-30T18:43:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Norm](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/norm/32/1096_2.png) [@Norm](https://discuss.gradle.org/u/Norm)\
**Post date:** [October 14, 2021, 4:07pm UTC](https://discuss.gradle.org/t/adding-a-dependency-for-a-buildsrc-script/41070/3 "2021-10-14T16:07:39Z")

</div>

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