I'm using Liquibase with Maven in a project - v4.2.0.
My changelogs are on the file system, rather than in the JAR or classpath of the project.
I'm using the following to establish my object:
liquibase = new Liquibase( changeLogFile, new FileSystemResourceAccessor(), database );
where the changelogFile
is something like ~/liquibase-sql/changelog/db.changelog.xml
When I call liquibase.validate()
, I get the following, after a reminder of the classpath locations:
Specifying files by absolute path was removed in Liquibase 4.0. Please use a relative path or add '/' to the classpath parameter.
I've tried various things including a file:
prefix, and the file is question can be opened in terminal directly.
I have looked through the code and I'm confused by the concept of FileSystemResourceAccessor
being named as such if it can only use the classpath (there's already a ClassLoaderResourceAccessor
), but I can't see a way to make it work.
Based on very very old questions people have managed this before, but I assume prior to 4.0? (this works fine on 3.10.3)
Does anyone have any pointers? I've used CLI liquibase and understand the error, but I'm not sure how I can not determine the path without it being absolute, on the understanding that this would be potentially be ran on a few different machines in arbitrary locations.
This might be niche question, but thanks for any help in advance.
Here is what I ended up doing (for a gradle-based project):
For gradle, this meant adding some stuff to build.gradle like so:
sourceSets {
test {
//whatever else you have
resources {
srcDir 'src/test/resources'
srcDir 'top-external-folder-of-changelog'
}
}
}
dependencies {
testImplementation files (path/to/external/folder)
}
The changelog schemaLocation attribute then looks like this:
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.11.xsd"
Remember to adjust for your version,
My specific issues was with tests. For real environments, the liquibase scripts are applied to the database via an external (liquibase-based) tool.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With