From ce7a3d0ef277a75a304799212892d517583647b8 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 3 Jan 2022 12:47:25 +0100 Subject: [PATCH] Upgrade to Flyway 8.3.0 Closes gh-29249 --- .../spring-boot-autoconfigure/build.gradle | 1 + .../flyway/FlywayAutoConfiguration.java | 15 +++++++++++---- .../flyway/FlywayAutoConfigurationTests.java | 16 ++++++++++++---- .../flyway/FlywayPropertiesTests.java | 4 +++- .../spring-boot-dependencies/build.gradle | 5 +++-- src/checkstyle/checkstyle.xml | 2 +- 6 files changed, 31 insertions(+), 12 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/build.gradle b/spring-boot-project/spring-boot-autoconfigure/build.gradle index feb44e09ff..28b0ced1b9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-autoconfigure/build.gradle @@ -114,6 +114,7 @@ dependencies { exclude group: "commons-logging", module: "commons-logging" } optional("org.flywaydb:flyway-core") + optional("org.flywaydb:flyway-sqlserver") optional("org.freemarker:freemarker") optional("org.glassfish.jersey.core:jersey-server") optional("org.glassfish.jersey.containers:jersey-container-servlet-core") diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java index 0b5a6cb6bd..57e66dcb7c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,8 @@ import org.flywaydb.core.api.MigrationVersion; import org.flywaydb.core.api.callback.Callback; import org.flywaydb.core.api.configuration.FluentConfiguration; import org.flywaydb.core.api.migration.JavaMigration; +import org.flywaydb.core.internal.plugin.PluginRegister; +import org.flywaydb.database.sqlserver.SQLServerConfigurationExtension; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfigureAfter; @@ -249,9 +251,8 @@ public class FlywayAutoConfiguration { // No method reference for compatibility with Flyway 6.x map.from(properties.getOutputQueryResults()) .to((outputQueryResults) -> configuration.outputQueryResults(outputQueryResults)); - // No method reference for compatibility with Flyway 6.x - map.from(properties.getSqlServerKerberosLoginFile()).to((sqlServerKerberosLoginFile) -> configuration - .sqlServerKerberosLoginFile(sqlServerKerberosLoginFile)); + map.from(properties.getSqlServerKerberosLoginFile()).whenNonNull() + .to(this::configureSqlServerKerberosLoginFile); // No method reference for compatibility with Flyway 6.x map.from(properties.getSkipExecutingMigrations()) .to((skipExecutingMigrations) -> configuration.skipExecutingMigrations(skipExecutingMigrations)); @@ -295,6 +296,12 @@ public class FlywayAutoConfiguration { } } + private void configureSqlServerKerberosLoginFile(String sqlServerKerberosLoginFile) { + SQLServerConfigurationExtension sqlServerConfigurationExtension = PluginRegister + .getPlugin(SQLServerConfigurationExtension.class); + sqlServerConfigurationExtension.setKerberosLoginFile(sqlServerKerberosLoginFile); + } + private void configureValidateMigrationNaming(FluentConfiguration configuration, boolean validateMigrationNaming) { try { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java index 3f79f222c4..c075006c14 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,8 @@ import org.flywaydb.core.api.callback.Context; import org.flywaydb.core.api.callback.Event; import org.flywaydb.core.api.migration.JavaMigration; import org.flywaydb.core.internal.license.FlywayTeamsUpgradeRequiredException; +import org.flywaydb.core.internal.plugin.PluginRegister; +import org.flywaydb.database.sqlserver.SQLServerConfigurationExtension; import org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform; import org.jooq.DSLContext; import org.jooq.SQLDialect; @@ -633,9 +635,15 @@ class FlywayAutoConfigurationTests { @Test void sqlServerKerberosLoginFileIsCorrectlyMapped() { - this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) - .withPropertyValues("spring.flyway.sql-server-kerberos-login-file=/tmp/config") - .run(validateFlywayTeamsPropertyOnly("sqlServer.kerberosLoginFile")); + try { + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("spring.flyway.sql-server-kerberos-login-file=/tmp/config") + .run(validateFlywayTeamsPropertyOnly("sqlserver.kerberos.login.file")); + } + finally { + // Reset to default value + PluginRegister.getPlugin(SQLServerConfigurationExtension.class).setKerberosLoginFile(null); + } } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayPropertiesTests.java index 123b66f027..0d680ec619 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -110,6 +110,8 @@ class FlywayPropertiesTests { // Properties specific settings ignoreProperties(properties, "url", "driverClassName", "user", "password", "enabled", "checkLocation", "createDataSource"); + // Property that moved to a separate SQL plugin + ignoreProperties(properties, "sqlServerKerberosLoginFile"); // High level object we can't set with properties ignoreProperties(configuration, "callbacks", "classLoader", "dataSource", "javaMigrations", "javaMigrationClassProvider", "resourceProvider", "resolvers"); diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 9826823c77..cfbced0e37 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -314,10 +314,11 @@ bom { ] } } - library("Flyway", "8.0.4") { + library("Flyway", "8.3.0") { group("org.flywaydb") { modules = [ - "flyway-core" + "flyway-core", + "flyway-sqlserver" ] plugins = [ "flyway-maven-plugin" diff --git a/src/checkstyle/checkstyle.xml b/src/checkstyle/checkstyle.xml index 8a0cf07b38..b9daaa1e1a 100644 --- a/src/checkstyle/checkstyle.xml +++ b/src/checkstyle/checkstyle.xml @@ -13,7 +13,7 @@ name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck"> + value="^sun.*, ^org\.apache\.commons\.(?!compress|dbcp2|logging|pool2).*, ^com\.datastax\.oss\.driver\.shaded.*, ^com\.google\.common.*, ^io\.micrometer\.shaded.*, ^org\.testcontainers\.shaded.*" />