-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework how to enable/activate Flyway
(cherry picked from commit f6027e8)
- Loading branch information
Showing
7 changed files
with
103 additions
and
53 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...sions/flyway/deployment/src/main/java/io/quarkus/flyway/FlywayAlwaysEnabledProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.quarkus.flyway; | ||
|
||
import org.flywaydb.core.extensibility.Plugin; | ||
|
||
import io.quarkus.deployment.Feature; | ||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.builditem.FeatureBuildItem; | ||
import io.quarkus.deployment.builditem.IndexDependencyBuildItem; | ||
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; | ||
import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem; | ||
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; | ||
|
||
public class FlywayAlwaysEnabledProcessor { | ||
|
||
@BuildStep | ||
void build(BuildProducer<FeatureBuildItem> featureProducer) { | ||
featureProducer.produce(new FeatureBuildItem(Feature.FLYWAY)); | ||
} | ||
|
||
/** | ||
* Reinitialize {@code InsertRowLock} to avoid using a cached seed when invoking {@code getNextRandomString} | ||
*/ | ||
@BuildStep | ||
public RuntimeReinitializedClassBuildItem reinitInsertRowLock() { | ||
return new RuntimeReinitializedClassBuildItem( | ||
"org.flywaydb.core.internal.database.InsertRowLock"); | ||
} | ||
|
||
@BuildStep | ||
public NativeImageResourceBuildItem resources() { | ||
return new NativeImageResourceBuildItem("org/flywaydb/database/version.txt"); | ||
} | ||
|
||
@BuildStep | ||
IndexDependencyBuildItem indexFlyway() { | ||
return new IndexDependencyBuildItem("org.flywaydb", "flyway-core"); | ||
} | ||
|
||
@BuildStep | ||
public ServiceProviderBuildItem flywayPlugins() { | ||
return ServiceProviderBuildItem.allProvidersFromClassPath(Plugin.class.getName()); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
extensions/flyway/deployment/src/main/java/io/quarkus/flyway/FlywayEnabled.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.quarkus.flyway; | ||
|
||
import java.util.function.BooleanSupplier; | ||
|
||
import io.quarkus.flyway.runtime.FlywayBuildTimeConfig; | ||
|
||
/** | ||
* Supplier that can be used to only run build steps | ||
* if the Flyway extension is enabled. | ||
*/ | ||
public class FlywayEnabled implements BooleanSupplier { | ||
|
||
private final FlywayBuildTimeConfig config; | ||
|
||
FlywayEnabled(FlywayBuildTimeConfig config) { | ||
this.config = config; | ||
} | ||
|
||
@Override | ||
public boolean getAsBoolean() { | ||
return config.enabled; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters