I have yml file with such property:
spring:
application:
name: auth module
profiles:
active: prod
In my gradle.build:
assume your yaml file has name cfg.yaml
don't forget to add ---
at the beginning of yaml
---
spring:
application:
name: auth module
profiles:
active: prod
build.gradle:
defaultTasks "testMe"
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.yaml', name: 'snakeyaml', version: '1.19'
}
}
def cfg = new org.yaml.snakeyaml.Yaml().load( new File("cfg.yaml").newInputStream() )
task testMe( ){
doLast {
println "make "
println "profile = ${cfg.spring.profiles.active}"
assert cfg.spring.profiles.active == "prod"
}
}