Including Dependencies in Your Gradle Build Script's Classpath

In a recent project, I wanted to use SnakeYAML in my Gradle build script. This is pretty easy to do; all you have to do is add the following to your script:

1
2
3
4
5
6
7
8
9
10
11
buildscript {
repositories {
mavenCentral()
// ...etc
}

dependencies {
classpath group: 'org.yaml', name: 'snakeyaml', version: '1.5'
// ..etc
}
}

This is the same as the repositories {} and dependencies {} sections of the build script. After doing this, feel free to use your libraries anywhere in your build script. Don’t forget to import the classes you use!


Thanks for reading my post! If you enjoyed it or it helped you, please consider liking/tweeting this page, commenting, or following me on GitHub or Twitter!