How to read the properties from yaml file in build.gradle using gradle task dev update command

I’m new gradle user.
I want to read based on spring profile active. Profile should be dynamically update. then how to apply in my code. below snippet is not working for me.
Could you help on this.

def cfg = new org.yaml.snakeyaml.Yaml().load( new File(“src/main/resources/application-${profile}.yml”).newInputStream() ) //not working this.

task(‘dev’) {
doLast {
liquibase {
activities {
main {
changeLogFile cfg.spring.liquibase.changelog
url cfg.spring.datasource.url
username cfg.spring.datasource.username
password cfg.spring.datasource.password
changeLogParameters([schemaName: cfg.custom.schemaName ])
runList = ‘main’