Skip to content

Commit

Permalink
fix: allow Flyway and Liquibase to play together by making JdbcDataSo…
Browse files Browse the repository at this point in the history
…urceSchemaReadyBuildItem a multiple build item

The liquibase extension was merged in quarkusio#6334 which means that we have multiple possibilities of making a DB schema ready.
This makes the build item that controls whether DB schemas are ready a mutliple build item so that it can be produced by several extensions.

Without this we have the following extensions when we try to cohabite Flyway and Liquibase
```
io.quarkus.builder.ChainBuildException: Multiple producers of item class
io.quarkus.agroal.deployment.JdbcDataSourceSchemaReadyBuildItem(io.quarkus.flyway.FlywayProcessor#configureRuntimeProperties)
```

Also avoid the usage of star imports in liquibase integration tests
  • Loading branch information
machi1990 authored and gsmet committed Mar 8, 2020
1 parent 4efda03 commit 30cdcb0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import java.util.Collection;

import io.quarkus.builder.item.SimpleBuildItem;
import io.quarkus.builder.item.MultiBuildItem;

/**
* A build item which can be used to order build processors which need a datasource's
* schema to be ready (which really means that the tables have been created and
* any migration run on them) for processing.
*/
public final class JdbcDataSourceSchemaReadyBuildItem extends SimpleBuildItem {
public final class JdbcDataSourceSchemaReadyBuildItem extends MultiBuildItem {

private final Collection<String> datasourceNames;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public void startPersistenceUnits(HibernateOrmRecorder recorder, BeanContainerBu
List<JdbcDataSourceBuildItem> dataSourcesConfigured,
JpaEntitiesBuildItem jpaEntities, List<NonJpaModelBuildItem> nonJpaModels,
List<HibernateOrmIntegrationRuntimeConfiguredBuildItem> integrationsRuntimeConfigured,
Optional<JdbcDataSourceSchemaReadyBuildItem> schemaReadyBuildItem) throws Exception {
List<JdbcDataSourceSchemaReadyBuildItem> schemaReadyBuildItem) throws Exception {
if (!hasEntities(jpaEntities, nonJpaModels)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public List<LogCleanupFilterBuildItem> logCleanup(QuartzBuildTimeConfig config)
public void build(QuartzRuntimeConfig runtimeConfig, QuartzBuildTimeConfig buildTimeConfig, QuartzRecorder recorder,
BeanContainerBuildItem beanContainer,
BuildProducer<ServiceStartBuildItem> serviceStart, QuartzJDBCDriverDialectBuildItem driverDialect,
Optional<JdbcDataSourceSchemaReadyBuildItem> schemaReadyBuildItem) {
List<JdbcDataSourceSchemaReadyBuildItem> schemaReadyBuildItem) {
recorder.initialize(runtimeConfig, buildTimeConfig, beanContainer.getValue(), driverDialect.getDriver());
// Make sure that StartupEvent is fired after the init
serviceStart.produce(new ServiceStartBuildItem("quartz"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
import java.util.stream.Collectors;

import javax.inject.Inject;
import javax.ws.rs.*;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;

import io.quarkus.liquibase.LiquibaseFactory;
Expand Down

0 comments on commit 30cdcb0

Please sign in to comment.