From 3cfda443ba01f0472d143db17a8ee65eb9fa0470 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Jun 2023 22:06:42 +0000 Subject: [PATCH] Bump flyway.version from 9.17.0 to 9.20.0 Bumps `flyway.version` from 9.17.0 to 9.20.0. Updates `flyway-core` from 9.17.0 to 9.20.0 - [Release notes](https://github.com/flyway/flyway/releases) - [Commits](https://github.com/flyway/flyway/compare/flyway-9.17.0...flyway-9.20.0) Updates `flyway-sqlserver` from 9.17.0 to 9.20.0 - [Release notes](https://github.com/flyway/flyway/releases) - [Commits](https://github.com/flyway/flyway/compare/flyway-9.17.0...flyway-9.20.0) Updates `flyway-mysql` from 9.17.0 to 9.20.0 - [Release notes](https://github.com/flyway/flyway/releases) - [Commits](https://github.com/flyway/flyway/compare/flyway-9.17.0...flyway-9.20.0) --- updated-dependencies: - dependency-name: org.flywaydb:flyway-core dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.flywaydb:flyway-sqlserver dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.flywaydb:flyway-mysql dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- bom/application/pom.xml | 7 +- docs/src/main/asciidoc/flyway.adoc | 9 +++ .../quarkus/flyway/runtime/FlywayCreator.java | 3 +- .../ClassicConfigurationSubstitutions.java | 66 +++++++++++++++++++ .../graal/OracleDatabaseTypeSubstitution.java | 13 +++- 5 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/graal/ClassicConfigurationSubstitutions.java diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 405aab8047687..da09865863983 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -168,7 +168,7 @@ 3.2.0 4.2.0 1.1.1 - 9.17.0 + 9.20.0 3.0.3 4.20.0 2.0 @@ -6252,6 +6252,11 @@ flyway-mysql ${flyway.version} + + org.flywaydb + flyway-database-oracle + ${flyway.version} + org.liquibase liquibase-core diff --git a/docs/src/main/asciidoc/flyway.adoc b/docs/src/main/asciidoc/flyway.adoc index 259a1b4088cd6..27ce233f27c3a 100644 --- a/docs/src/main/asciidoc/flyway.adoc +++ b/docs/src/main/asciidoc/flyway.adoc @@ -28,6 +28,7 @@ In your build file, add the following dependencies: * your JDBC driver extension (`quarkus-jdbc-postgresql`, `quarkus-jdbc-h2`, `quarkus-jdbc-mariadb`, ...) * the MariaDB/MySQL support is now in a separate dependency, MariaDB/MySQL users need to add the `flyway-mysql` dependency from now on. * the Microsoft SQL Server support is now in a separate dependency, Microsoft SQL Server users need to add the `flyway-sqlserver` dependency from now on. +* the Oracle support is now in a separate dependency, Oracle users need to add the `flyway-database-oracle` dependency from now on. [source,xml,role="primary asciidoc-tabs-target-sync-cli asciidoc-tabs-target-sync-maven"] .pom.xml @@ -50,6 +51,12 @@ In your build file, add the following dependencies: flyway-mysql + + + org.flywaydb + flyway-database-oracle + + io.quarkus @@ -66,6 +73,8 @@ implementation("io.quarkus:quarkus-flyway") implementation("org.flywaydb:flyway-sqlserver") // Flyway MariaDB/MySQL specific dependencies implementation("org.flywaydb:flyway-mysql") +// Flyway Oracle specific dependencies +implementation("org.flywaydb:flyway-database-oracle") // JDBC driver dependencies implementation("io.quarkus:quarkus-jdbc-postgresql") ---- diff --git a/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayCreator.java b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayCreator.java index 1c7b2222b9710..45ef59cbed10b 100644 --- a/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayCreator.java +++ b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayCreator.java @@ -67,8 +67,7 @@ public Flyway createFlyway(DataSource dataSource) { configure.dataSource(jdbcUrl, flywayRuntimeConfig.username.get(), flywayRuntimeConfig.password.get()); - } else { - + } else if (dataSource != null) { configure.dataSource(dataSource); } } diff --git a/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/graal/ClassicConfigurationSubstitutions.java b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/graal/ClassicConfigurationSubstitutions.java new file mode 100644 index 0000000000000..6ee61f922bb4b --- /dev/null +++ b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/graal/ClassicConfigurationSubstitutions.java @@ -0,0 +1,66 @@ +package io.quarkus.flyway.runtime.graal; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.flywaydb.core.extensibility.ConfigurationExtension; +import org.flywaydb.core.internal.plugin.PluginRegister; +import org.flywaydb.core.internal.util.MergeUtils; + +import com.google.gson.Gson; +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.RecomputeFieldValue; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; + +@TargetClass(className = "org.flywaydb.core.api.configuration.ClassicConfiguration") +public final class ClassicConfigurationSubstitutions { + + @Alias + @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias) + private static Pattern ANY_WORD_BETWEEN_TWO_QUOTES_PATTERN = Pattern.compile("\"([^\"]*)\""); + + @Alias + PluginRegister pluginRegister; + + @Substitute + private void determineKeysToRemoveAndRemoveFromProps(HashMap> configExtensionsPropertyMap, + List keysToRemove, Map props) { + for (Map.Entry> property : configExtensionsPropertyMap.entrySet()) { + ConfigurationExtension cfg = null; + for (ConfigurationExtension c : pluginRegister.getPlugins(ConfigurationExtension.class)) { + if (c.getClass().toString().equals(property.getKey())) { + cfg = c; + break; + } + } + if (cfg != null) { + Map mp = property.getValue(); + try { + Gson gson = new Gson(); + ConfigurationExtension newConfigurationExtension = gson.fromJson(gson.toJson(mp), cfg.getClass()); + MergeUtils.mergeModel(newConfigurationExtension, cfg); + } catch (Exception e) { + Matcher matcher = ANY_WORD_BETWEEN_TWO_QUOTES_PATTERN.matcher(e.getMessage()); + if (matcher.find()) { + String errorProperty = matcher.group(1); + List propsToRemove = new ArrayList<>(); + for (String k : keysToRemove) { + if (k.endsWith(errorProperty)) { + propsToRemove.add(k); + } + } + keysToRemove.removeAll(propsToRemove); + } + } + } + } + + props.keySet().removeAll(keysToRemove); + } + +} diff --git a/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/graal/OracleDatabaseTypeSubstitution.java b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/graal/OracleDatabaseTypeSubstitution.java index 9363bf1175e5b..67001f0d8c9f8 100644 --- a/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/graal/OracleDatabaseTypeSubstitution.java +++ b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/graal/OracleDatabaseTypeSubstitution.java @@ -4,7 +4,6 @@ import java.util.function.BooleanSupplier; import org.flywaydb.core.api.configuration.Configuration; -import org.flywaydb.core.internal.database.oracle.OracleDatabaseType; import org.flywaydb.core.internal.util.ClassUtils; import com.oracle.svm.core.annotate.Substitute; @@ -13,7 +12,9 @@ /** * Avoid loading the oracle.jdbc.OracleConnection class if unavailable */ -@TargetClass(value = OracleDatabaseType.class, onlyWith = OracleDatabaseTypeSubstitution.OracleDriverUnavailable.class) +@TargetClass(className = "org.flywaydb.database.oracle.OracleDatabaseType", onlyWith = { + OracleDatabaseTypeSubstitution.OracleAvailable.class, + OracleDatabaseTypeSubstitution.OracleDriverUnavailable.class }) public final class OracleDatabaseTypeSubstitution { @Substitute @@ -27,4 +28,12 @@ public boolean getAsBoolean() { return !ClassUtils.isPresent("oracle.jdbc.OracleConnection", Thread.currentThread().getContextClassLoader()); } } + + public static final class OracleAvailable implements BooleanSupplier { + @Override + public boolean getAsBoolean() { + return ClassUtils.isPresent("org.flywaydb.database.oracle.OracleDatabaseType", + Thread.currentThread().getContextClassLoader()); + } + } }