Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
483 views
in Technique[技术] by (71.8m points)

java - liquibase 3.5.X can't find any files for includeAll with relative path

We are using liquibase 3.4.2 and want to update to 3.5.3 but all my attempts failed because liquibase doesn't find any file which are included by using includeAll. I have tested liquibase 3.5.0, 3.5.1 and 3.5.3 (I skipped 3.5.2 because of this blog post).

My ChangeSet looks like this:

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
               xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">

    <includeAll path="relative/dir1" relativeToChangelogFile="true" errorIfMissingOrEmpty="true"/>
    <includeAll path="relative/dir2" relativeToChangelogFile="true" errorIfMissingOrEmpty="true"/>

</databaseChangeLog>

My directory structure (inside a jar which is included in a war) looks like this:

  • /some/dir/changeset.xml (the code above)
  • /some/dir/relative/dir1/another-changeset.xml
  • /some/dir/relative/dir2/another-changeset-1.xml
  • /some/dir/relative/dir2/another-changeset-2.xml

I have already debugged through liquibase and got stuck at ClassLoaderResourceAccessor.java:108:

if (entry.getName().startsWith(path)) {

In my case entry.getName() returns some in the first loop, then some/dir and so on till some/dir/relative/dir1/another-changeset-1.xml, some/dir/relative/dir2/another-changeset-1.xml and some/dir/relative/dir2/another-changeset-2.xml. But the condition is always false because path contains something like jar:file:/C:/path/to/maven/project/war/target/example.war-1.0-SNAPSHOT/WEB-INF/lib/changesets-1.0-SNAPSHOT.jar!/relative/dir1/ or jar:file:/C:/path/to/maven/project/war/target/example.war-1.0-SNAPSHOT/WEB-INF/lib/changesets-1.0-SNAPSHOT.jar!/relative/dir2/

Is this really a bug in liquibase since 3.5.0? It works perfectly if I downgrade to liquibase 3.4.2. It works also if I use include instead of includeAll but in my real application I have much more changesets and I don't want to list them all manually.

I have found some information on this, but none of them helps me. For the sake of completeness:

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try this,

<includeAll path="file:/absolute/path/to/changeset/folder" relativeToChangelogFile="false" />

Start the path with file:/ and use an absolute path. This is not ideal, but I was able to get liquibase-maven-plugin 3.6.3 to load the changeset.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...