diff --git a/extensions/liquibase-mongodb/runtime/src/main/java/io/quarkus/liquibase/mongodb/LiquibaseMongodbFactory.java b/extensions/liquibase-mongodb/runtime/src/main/java/io/quarkus/liquibase/mongodb/LiquibaseMongodbFactory.java index ef8819d730185..0286f923a9614 100644 --- a/extensions/liquibase-mongodb/runtime/src/main/java/io/quarkus/liquibase/mongodb/LiquibaseMongodbFactory.java +++ b/extensions/liquibase-mongodb/runtime/src/main/java/io/quarkus/liquibase/mongodb/LiquibaseMongodbFactory.java @@ -40,21 +40,24 @@ public LiquibaseMongodbFactory(LiquibaseMongodbConfig config, private ResourceAccessor resolveResourceAccessor() throws FileNotFoundException { - if (liquibaseMongodbBuildTimeConfig.changeLog.startsWith("classpath:")) { - return new ClassLoaderResourceAccessor(Thread.currentThread().getContextClassLoader()); - } - - if (!liquibaseMongodbBuildTimeConfig.changeLog.startsWith("filesystem:") && - liquibaseMongodbBuildTimeConfig.searchPath.size() == 1 && - liquibaseMongodbBuildTimeConfig.searchPath.get(0).equals("/")) { - return new ClassLoaderResourceAccessor(Thread.currentThread().getContextClassLoader()); - } - CompositeResourceAccessor compositeResourceAccessor = new CompositeResourceAccessor(); compositeResourceAccessor .addResourceAccessor(new ClassLoaderResourceAccessor(Thread.currentThread().getContextClassLoader())); - for (String searchPath : liquibaseMongodbBuildTimeConfig.searchPath) { + if (!liquibaseMongodbBuildTimeConfig.changeLog.startsWith("filesystem:") + && liquibaseMongodbBuildTimeConfig.searchPath.isEmpty()) { + return compositeResourceAccessor; + } + + if (liquibaseMongodbBuildTimeConfig.searchPath.isEmpty()) { + compositeResourceAccessor.addResourceAccessor( + new DirectoryResourceAccessor( + Paths.get(StringUtil.changePrefix(liquibaseMongodbBuildTimeConfig.changeLog, "filesystem:", "")) + .getParent())); + return compositeResourceAccessor; + } + + for (String searchPath : liquibaseMongodbBuildTimeConfig.searchPath.get()) { compositeResourceAccessor.addResourceAccessor(new DirectoryResourceAccessor(Paths.get(searchPath))); } @@ -62,6 +65,11 @@ private ResourceAccessor resolveResourceAccessor() throws FileNotFoundException } private String parseChangeLog(String changeLog) { + + if (changeLog.startsWith("filesystem:") && liquibaseMongodbBuildTimeConfig.searchPath.isEmpty()) { + return Paths.get(StringUtil.changePrefix(changeLog, "filesystem:", "")).getFileName().toString(); + } + if (changeLog.startsWith("filesystem:")) { return StringUtil.changePrefix(changeLog, "filesystem:", ""); } diff --git a/extensions/liquibase-mongodb/runtime/src/main/java/io/quarkus/liquibase/mongodb/runtime/LiquibaseMongodbBuildTimeConfig.java b/extensions/liquibase-mongodb/runtime/src/main/java/io/quarkus/liquibase/mongodb/runtime/LiquibaseMongodbBuildTimeConfig.java index 9267af734848b..a06832603b4af 100644 --- a/extensions/liquibase-mongodb/runtime/src/main/java/io/quarkus/liquibase/mongodb/runtime/LiquibaseMongodbBuildTimeConfig.java +++ b/extensions/liquibase-mongodb/runtime/src/main/java/io/quarkus/liquibase/mongodb/runtime/LiquibaseMongodbBuildTimeConfig.java @@ -1,6 +1,7 @@ package io.quarkus.liquibase.mongodb.runtime; import java.util.List; +import java.util.Optional; import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; @@ -21,6 +22,6 @@ public class LiquibaseMongodbBuildTimeConfig { /** * The search path for DirectoryResourceAccessor */ - @ConfigItem(defaultValue = "/") - public List searchPath; + @ConfigItem + public Optional> searchPath; }