4

I'm using Gradle 2.7 with the Gradle Liquibase plugin v 1.1.1. How do I run my changeSets as part of doing my normal build using

gradle build

? I currently have this in my build.gradle file ...

liquibase {
  activities {
    main {
        File propsFile = new File("${project.rootDir}/src/main/resources/liquibase.properties")
      Properties properties = new Properties()
      properties.load(new FileInputStream(propsFile))
      changeLogFile 'src/main/resources/db.changelog-1.0.xmlll'
      url '${url}'
      username '${username}'
      password '${password}'
    }
    runList = main
  }
}

However when I run the above command ("gradle build"), the above is not run. I know its not run because the username/password are incorrect and I have no change log file ending in ".xmlll". WHat else do I need to add to assure that hte plugin always attempts to execute the changeset?

Dave
  • 15,639
  • 133
  • 442
  • 830

2 Answers2

5

You need to define a task dependency from build to update.

build.dependsOn update

To get task to run before your tests (assuming you didn't define a new one), you can do

test.dependsOn update

Ref:

Ethan
  • 6,883
  • 3
  • 33
  • 41
0

You can define this in your gradle build file

apply plugin: 'liquibase'
dependencies {
  classpath 'org.liquibase:liquibase-gradle-plugin:1.2.0'
}
liquibase {
  activities {
     main {
  changeLogFile 'changelog.xml'
  url 'jdbc:h2:db/liquibase_workshop;FILE_LOCK=NO'
  username 'sa'
  password ''
      }
 }

And then run this command
gradle update

rhozet
  • 542
  • 1
  • 6
  • 17