diff --git a/extensions/liquibase/deployment/src/main/java/io/quarkus/liquibase/deployment/LiquibaseProcessor.java b/extensions/liquibase/deployment/src/main/java/io/quarkus/liquibase/deployment/LiquibaseProcessor.java index 33188df5e78e6..4d6c65e2b30f5 100644 --- a/extensions/liquibase/deployment/src/main/java/io/quarkus/liquibase/deployment/LiquibaseProcessor.java +++ b/extensions/liquibase/deployment/src/main/java/io/quarkus/liquibase/deployment/LiquibaseProcessor.java @@ -28,6 +28,7 @@ import org.jboss.jandex.DotName; import org.jboss.logging.Logger; +import io.quarkus.agroal.runtime.DataSources; import io.quarkus.agroal.spi.JdbcDataSourceBuildItem; import io.quarkus.agroal.spi.JdbcDataSourceSchemaReadyBuildItem; import io.quarkus.arc.deployment.AdditionalBeanBuildItem; @@ -285,6 +286,7 @@ void createBeans(LiquibaseRecorder recorder, .setRuntimeInit() .unremovable() .addInjectionPoint(ClassType.create(DotName.createSimple(LiquibaseFactoryProducer.class))) + .addInjectionPoint(ClassType.create(DotName.createSimple(DataSources.class))) .createWith(recorder.liquibaseFunction(dataSourceName)); if (DataSourceUtil.isDefault(dataSourceName)) { diff --git a/extensions/liquibase/runtime/src/main/java/io/quarkus/liquibase/runtime/LiquibaseRecorder.java b/extensions/liquibase/runtime/src/main/java/io/quarkus/liquibase/runtime/LiquibaseRecorder.java index 2b9429b73d5bf..d85785d61e35b 100644 --- a/extensions/liquibase/runtime/src/main/java/io/quarkus/liquibase/runtime/LiquibaseRecorder.java +++ b/extensions/liquibase/runtime/src/main/java/io/quarkus/liquibase/runtime/LiquibaseRecorder.java @@ -29,21 +29,16 @@ public LiquibaseRecorder(RuntimeValue config) { } public Function, LiquibaseFactory> liquibaseFunction(String dataSourceName) { - DataSource dataSource = DataSources.fromName(dataSourceName); - if (dataSource instanceof UnconfiguredDataSource) { - return new Function, LiquibaseFactory>() { - @Override - public LiquibaseFactory apply(SyntheticCreationalContext context) { - throw new UnsatisfiedResolutionException("No datasource has been configured"); - } - }; - } return new Function, LiquibaseFactory>() { @Override public LiquibaseFactory apply(SyntheticCreationalContext context) { + DataSource dataSource = context.getInjectedReference(DataSources.class).getDataSource(dataSourceName); + if (dataSource instanceof UnconfiguredDataSource) { + throw new UnsatisfiedResolutionException("No datasource has been configured"); + } + LiquibaseFactoryProducer liquibaseProducer = context.getInjectedReference(LiquibaseFactoryProducer.class); - LiquibaseFactory liquibaseFactory = liquibaseProducer.createLiquibaseFactory(dataSource, dataSourceName); - return liquibaseFactory; + return liquibaseProducer.createLiquibaseFactory(dataSource, dataSourceName); } }; }