liquibase / liquibase-gradle-plugin

A Gradle plugin for Liquibase
Other
197 stars 57 forks source link

Specify working directory #57

Closed matteoturra closed 5 years ago

matteoturra commented 5 years ago

I put my change log in the src/main/db directory. Is it possible to specify this directory as "working directory" used to resolve absolute path in include element. Which is the default directory from which all path are resolved launching the plugin tasks?

stevesaliman commented 5 years ago

The default directory for resolving relative paths is the root directory of the project.

Let's say that your main changelog is in src/main/db, and the included changelogs are in src/main/db/include. , There are two ways you can resolve paths in an include element.

The first is to use path: "src/main/db/include" in your include elements, which tells Liquibase to find them relative to Gradle's working directory

The second is to use path: 'include', relativeToChangelogFile: true in your include elements, which tells Liquibase to find them relative to the changelog file itself.

gavenkoa commented 2 years ago

Check https://stackoverflow.com/questions/27187979/gradle-liquibase-change-log-file-could-not-be-found

liquibase {
   activities {
      main {
         // Real path: $subproj/src/main/resources/db/master.xml
         changeLogFile 'db/master.xml'
         // Allows to strip "src/main/resources".
         classpath "${projectDir}/src/main/resources"

         url 'jdbc:mysql://localhost:3306/test'
         username 'XXX'
         password 'XXX'
     }
  }
 runList = 'main'
}