How to read different profile properties(DEV,QA,PROD) using application.properties file in liquibase using gradle task {profile}update

How to read different profile properties(DEV,QA,PROD) using application.properties file in liquibase using gradle task dev update.

I want to read properties for all profiles like this

        **url props.getProperty("spring.datasource.url")**

** username props.getProperty(“spring.datasource.username”)**
** password props.getProperty(“spring.datasource.password”)**
** changeLogParameters([schemaName: ‘devSchema’])**

I want to read properties file like below…How do i read dynamically using this build script

def props = new Properties()
file(“src/main/resources/application-{profile}.properties”).withInputStream { props.load(it) }

For example script:

def props = new Properties()
file(“src/main/resources/application.properties”).withInputStream { props.load(it) }

diff.dependsOn assemble
diffChangeLog.dependsOn assemble

def changeLog = props.getProperty(“spring.liquibase.change-log”)
task(‘local’) {
doLast {
liquibase {
activities {
main {
changeLogFile changeLog
url props.getProperty(“spring.datasource.url”)
username props.getProperty(“spring.datasource.username”)
password props.getProperty(“spring.datasource.password”)
changeLogParameters([schemaName: ‘devSchema’])

    }
}
runList = 'main'

}
}
}
task(‘dev’) {
doLast {
println “executing dev”

liquibase {
    activities {
        main {
            changeLogFile 'src/main/resources/db/db.changelog-master.yml'
            url 'jdbc:postgresql://localhost:5432/postgres'
            username 'postgres'
            password 'postgres'
        }
      }
    }
}    

}

task(‘qa’) {
doLast {
println “executing qa”

liquibase {
    activities {
        main {
            changeLogFile changeLog
            url 'jdbc:postgresql://localhost:5432/postgres'
            username 'postgres'
            password 'postgres'
            
        }
      }
    }
}

Hi @Simhadri ,

This questions seems to be more about how to do something in Spring and Gradle that happens to use Liquibase. I respectfully opine that you would get faster response on consuming proeprties from an application.properties file from:

If you run into a Liquibase issue, or I misunderstood your question, please feel free to comment back.

Thanks,

Ronak