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

While reading the properties from yaml file getting below error. Could please help on this.

Unexpected error running Liquibase: java.lang.RuntimeException: Driver class was not specified and could not be determined from the url (null)
For more information, please use the --logLevel flag
[2021-02-04 19:20:05] SEVERE [liquibase.integration] Unexpected error running Liquibase: java.lang.RuntimeException: Driver class was not specified and could not be determined from the url (null)
liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.lang.RuntimeException: Driver class was not specified and could not be determined from the url (null)
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:131)
at liquibase.integration.commandline.Main.doMigration(Main.java:1409)
at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:361)

Example

diff.dependsOn assemble
diffChangeLog.dependsOn assemble
diffChangeLog.dependsOn build

def cfg = new org.yaml.snakeyaml.Yaml().load( new File(“src/main/resources/application.yml”).newInputStream() )
task(‘dev’) {
doLast {

** liquibase {**
** activities {**
** main {**
** changeLogFile ‘src/main/resources/db/db.changelog-dev-master.yml’**
** url cfg[‘spring.datasource.url’]**
** username cfg[‘spring.datasource.username’]**
** password cfg[‘spring.datasource.password’]**


** }**
** }**
** runList = ‘main’**
** }**
** } **
}

Hi @Simhadri ,

I responded to another post, I don’t think this is a liquibase error, and sorry my primary expertise is not Spring or Gradle, or yaml either.

I’ll leave the post open in case others in the Liquibase community can help (as we do have Spring and Gradle users) but even though there are others on the forum with those expertise, I pointed out in the other post, I think you would find more help in the Spring or Gradle forums.

Thanks @ronak.
I resolved this. no worries.

1 Like

Glad to hear @Simhadri !

Just curious in case someone else runs into the issue, how did you resolve?

Hey @ronak
I did this below and able to read properties from yaml file.

def cfg = new org.yaml.snakeyaml.Yaml().load( new File(“src/main/resources/application-local.yml”).newInputStream() )

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.schema.name ])

        }
      }
    }

@Simhadri , you are awesome for sharing! Many thanks (and I am sure the Liquibase community appreciates it too)! You should join us on our legends program!

1 Like