We are trying to validate an yaml at the time of build in a gradle project. After adding the dependency "org.yaml.snakeyaml:2.2", and trying to use that on a task, I'm getting the error unable to resolve class org.yaml.snakeyaml.Yaml . Its throwing the even when I try to do gradlew clean.
repositories {
mavenCentral()
}
dependencies {
implementation 'org.yaml:snakeyaml:2.0'
}
task validateYaml {
doLast {
def yaml = new org.yaml.snakeyaml.Yaml()
def data = yaml.load(PATH_OF_YAML)
}
}
I tried with the older versions of snakeyaml. Its the same issue with any versions. Kindly let me know if there is anything I'm missing on this.
When you write:
you are making SnakeYAML a dependency of your application, not your build.
To add the dependency to the build, you need to use the buildscript block, like so: