Skip to content

Commit c6e47b8

Browse files
committed
Move Flyway configuration extension properties to dedicated namespace
This commit harmonizes the handling of ConfigurationExtension for Flyway. The existing Oracle and SQLServer extensions are now mapped from flway.oracle and flyway.sqlserver, respectively. The existing properties have been deprecated in favor of the new location. Closes gh-36444
1 parent 8da7066 commit c6e47b8

File tree

4 files changed

+194
-49
lines changed

4 files changed

+194
-49
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
5353
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration.FlywayAutoConfigurationRuntimeHints;
5454
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration.FlywayDataSourceCondition;
55+
import org.springframework.boot.autoconfigure.flyway.FlywayProperties.Oracle;
5556
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
5657
import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails;
5758
import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
@@ -477,10 +478,11 @@ public void customize(FluentConfiguration configuration) {
477478
Assert.notNull(extension, "Flyway Oracle extension missing");
478479
return extension;
479480
});
480-
map.apply(this.properties.getOracleSqlplus(), OracleConfigurationExtension::setSqlplus);
481-
map.apply(this.properties.getOracleSqlplusWarn(), OracleConfigurationExtension::setSqlplusWarn);
482-
map.apply(this.properties.getOracleWalletLocation(), OracleConfigurationExtension::setWalletLocation);
483-
map.apply(this.properties.getOracleKerberosCacheFile(), OracleConfigurationExtension::setKerberosCacheFile);
481+
Oracle oracle = this.properties.getOracle();
482+
map.apply(oracle.getSqlplus(), OracleConfigurationExtension::setSqlplus);
483+
map.apply(oracle.getSqlplusWarn(), OracleConfigurationExtension::setSqlplusWarn);
484+
map.apply(oracle.getWalletLocation(), OracleConfigurationExtension::setWalletLocation);
485+
map.apply(oracle.getKerberosCacheFile(), OracleConfigurationExtension::setKerberosCacheFile);
484486
}
485487

486488
}
@@ -528,7 +530,7 @@ public void customize(FluentConfiguration configuration) {
528530
return extension;
529531
});
530532

531-
map.apply(this.properties.getSqlServerKerberosLoginFile(),
533+
map.apply(this.properties.getSqlserver().getKerberosLoginFile(),
532534
(extension, file) -> extension.getKerberos().getLogin().setFile(file));
533535
}
534536

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java

Lines changed: 119 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.Map;
2929

3030
import org.springframework.boot.context.properties.ConfigurationProperties;
31+
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
3132
import org.springframework.boot.convert.DurationUnit;
3233

3334
/**
@@ -295,17 +296,6 @@ public class FlywayProperties {
295296
*/
296297
private String licenseKey;
297298

298-
/**
299-
* Whether to enable support for Oracle SQL*Plus commands. Requires Flyway Teams.
300-
*/
301-
private Boolean oracleSqlplus;
302-
303-
/**
304-
* Whether to issue a warning rather than an error when a not-yet-supported Oracle
305-
* SQL*Plus statement is encountered. Requires Flyway Teams.
306-
*/
307-
private Boolean oracleSqlplusWarn;
308-
309299
/**
310300
* Whether to stream SQL migrations when executing them. Requires Flyway Teams.
311301
*/
@@ -332,28 +322,12 @@ public class FlywayProperties {
332322
*/
333323
private String kerberosConfigFile;
334324

335-
/**
336-
* Path of the Oracle Kerberos cache file. Requires Flyway Teams.
337-
*/
338-
private String oracleKerberosCacheFile;
339-
340-
/**
341-
* Location of the Oracle Wallet, used to sign in to the database automatically.
342-
* Requires Flyway Teams.
343-
*/
344-
private String oracleWalletLocation;
345-
346325
/**
347326
* Whether Flyway should output a table with the results of queries when executing
348327
* migrations. Requires Flyway Teams.
349328
*/
350329
private Boolean outputQueryResults;
351330

352-
/**
353-
* Path to the SQL Server Kerberos login file. Requires Flyway Teams.
354-
*/
355-
private String sqlServerKerberosLoginFile;
356-
357331
/**
358332
* Whether Flyway should skip executing the contents of the migrations and only update
359333
* the schema history table. Requires Flyway teams.
@@ -372,8 +346,12 @@ public class FlywayProperties {
372346
*/
373347
private Boolean detectEncoding;
374348

349+
private final Oracle oracle = new Oracle();
350+
375351
private final Postgresql postgresql = new Postgresql();
376352

353+
private final Sqlserver sqlserver = new Sqlserver();
354+
377355
public boolean isEnabled() {
378356
return this.enabled;
379357
}
@@ -758,28 +736,37 @@ public void setLicenseKey(String licenseKey) {
758736
this.licenseKey = licenseKey;
759737
}
760738

739+
@DeprecatedConfigurationProperty(replacement = "spring.flyway.oracle.sqlplus")
740+
@Deprecated(since = "3.2.0", forRemoval = true)
761741
public Boolean getOracleSqlplus() {
762-
return this.oracleSqlplus;
742+
return getOracle().getSqlplus();
763743
}
764744

745+
@Deprecated(since = "3.2.0", forRemoval = true)
765746
public void setOracleSqlplus(Boolean oracleSqlplus) {
766-
this.oracleSqlplus = oracleSqlplus;
747+
getOracle().setSqlplus(oracleSqlplus);
767748
}
768749

750+
@DeprecatedConfigurationProperty(replacement = "spring.flyway.oracle.sqlplus-warn")
751+
@Deprecated(since = "3.2.0", forRemoval = true)
769752
public Boolean getOracleSqlplusWarn() {
770-
return this.oracleSqlplusWarn;
753+
return getOracle().getSqlplusWarn();
771754
}
772755

756+
@Deprecated(since = "3.2.0", forRemoval = true)
773757
public void setOracleSqlplusWarn(Boolean oracleSqlplusWarn) {
774-
this.oracleSqlplusWarn = oracleSqlplusWarn;
758+
getOracle().setSqlplusWarn(oracleSqlplusWarn);
775759
}
776760

761+
@DeprecatedConfigurationProperty(replacement = "spring.flyway.oracle.wallet-location")
762+
@Deprecated(since = "3.2.0", forRemoval = true)
777763
public String getOracleWalletLocation() {
778-
return this.oracleWalletLocation;
764+
return getOracle().getWalletLocation();
779765
}
780766

767+
@Deprecated(since = "3.2.0", forRemoval = true)
781768
public void setOracleWalletLocation(String oracleWalletLocation) {
782-
this.oracleWalletLocation = oracleWalletLocation;
769+
getOracle().setWalletLocation(oracleWalletLocation);
783770
}
784771

785772
public Boolean getStream() {
@@ -822,12 +809,15 @@ public void setKerberosConfigFile(String kerberosConfigFile) {
822809
this.kerberosConfigFile = kerberosConfigFile;
823810
}
824811

812+
@DeprecatedConfigurationProperty(replacement = "spring.flyway.oracle.kerberos-cache-file")
813+
@Deprecated(since = "3.2.0", forRemoval = true)
825814
public String getOracleKerberosCacheFile() {
826-
return this.oracleKerberosCacheFile;
815+
return getOracle().getKerberosCacheFile();
827816
}
828817

818+
@Deprecated(since = "3.2.0", forRemoval = true)
829819
public void setOracleKerberosCacheFile(String oracleKerberosCacheFile) {
830-
this.oracleKerberosCacheFile = oracleKerberosCacheFile;
820+
getOracle().setKerberosCacheFile(oracleKerberosCacheFile);
831821
}
832822

833823
public Boolean getOutputQueryResults() {
@@ -838,12 +828,15 @@ public void setOutputQueryResults(Boolean outputQueryResults) {
838828
this.outputQueryResults = outputQueryResults;
839829
}
840830

831+
@DeprecatedConfigurationProperty(replacement = "spring.flyway.sqlserver.kerberos-login-file")
832+
@Deprecated(since = "3.2.0", forRemoval = true)
841833
public String getSqlServerKerberosLoginFile() {
842-
return this.sqlServerKerberosLoginFile;
834+
return getSqlserver().getKerberosLoginFile();
843835
}
844836

837+
@Deprecated(since = "3.2.0", forRemoval = true)
845838
public void setSqlServerKerberosLoginFile(String sqlServerKerberosLoginFile) {
846-
this.sqlServerKerberosLoginFile = sqlServerKerberosLoginFile;
839+
getSqlserver().setKerberosLoginFile(sqlServerKerberosLoginFile);
847840
}
848841

849842
public Boolean getSkipExecutingMigrations() {
@@ -870,10 +863,79 @@ public void setDetectEncoding(final Boolean detectEncoding) {
870863
this.detectEncoding = detectEncoding;
871864
}
872865

866+
public Oracle getOracle() {
867+
return this.oracle;
868+
}
869+
873870
public Postgresql getPostgresql() {
874871
return this.postgresql;
875872
}
876873

874+
public Sqlserver getSqlserver() {
875+
return this.sqlserver;
876+
}
877+
878+
/**
879+
* {@code OracleConfigurationExtension} properties.
880+
*/
881+
public static class Oracle {
882+
883+
/**
884+
* Whether to enable support for Oracle SQL*Plus commands. Requires Flyway Teams.
885+
*/
886+
private Boolean sqlplus;
887+
888+
/**
889+
* Whether to issue a warning rather than an error when a not-yet-supported Oracle
890+
* SQL*Plus statement is encountered. Requires Flyway Teams.
891+
*/
892+
private Boolean sqlplusWarn;
893+
894+
/**
895+
* Path of the Oracle Kerberos cache file. Requires Flyway Teams.
896+
*/
897+
private String kerberosCacheFile;
898+
899+
/**
900+
* Location of the Oracle Wallet, used to sign in to the database automatically.
901+
* Requires Flyway Teams.
902+
*/
903+
private String walletLocation;
904+
905+
public Boolean getSqlplus() {
906+
return this.sqlplus;
907+
}
908+
909+
public void setSqlplus(Boolean sqlplus) {
910+
this.sqlplus = sqlplus;
911+
}
912+
913+
public Boolean getSqlplusWarn() {
914+
return this.sqlplusWarn;
915+
}
916+
917+
public void setSqlplusWarn(Boolean sqlplusWarn) {
918+
this.sqlplusWarn = sqlplusWarn;
919+
}
920+
921+
public String getKerberosCacheFile() {
922+
return this.kerberosCacheFile;
923+
}
924+
925+
public void setKerberosCacheFile(String kerberosCacheFile) {
926+
this.kerberosCacheFile = kerberosCacheFile;
927+
}
928+
929+
public String getWalletLocation() {
930+
return this.walletLocation;
931+
}
932+
933+
public void setWalletLocation(String walletLocation) {
934+
this.walletLocation = walletLocation;
935+
}
936+
937+
}
938+
877939
/**
878940
* {@code PostgreSQLConfigurationExtension} properties.
879941
*/
@@ -895,4 +957,24 @@ public void setTransactionalLock(Boolean transactionalLock) {
895957

896958
}
897959

960+
/**
961+
* {@code SQLServerConfigurationExtension} properties.
962+
*/
963+
public static class Sqlserver {
964+
965+
/**
966+
* Path to the SQL Server Kerberos login file. Requires Flyway Teams.
967+
*/
968+
private String kerberosLoginFile;
969+
970+
public String getKerberosLoginFile() {
971+
return this.kerberosLoginFile;
972+
}
973+
974+
public void setKerberosLoginFile(String kerberosLoginFile) {
975+
this.kerberosLoginFile = kerberosLoginFile;
976+
}
977+
978+
}
979+
898980
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,19 @@ void oracleExtensionIsNotLoadedByDefault() {
618618

619619
@Test
620620
void oracleSqlplusIsCorrectlyMapped() {
621+
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
622+
.withPropertyValues("spring.flyway.oracle.sqlplus=true")
623+
.run((context) -> assertThat(context.getBean(Flyway.class)
624+
.getConfiguration()
625+
.getPluginRegister()
626+
.getPlugin(OracleConfigurationExtension.class)
627+
.getSqlplus()).isTrue());
628+
629+
}
630+
631+
@Test
632+
@Deprecated(since = "3.2.0", forRemoval = true)
633+
void oracleSqlplusIsCorrectlyMappedWithDeprecatedProperty() {
621634
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
622635
.withPropertyValues("spring.flyway.oracle-sqlplus=true")
623636
.run((context) -> assertThat(context.getBean(Flyway.class)
@@ -630,6 +643,18 @@ void oracleSqlplusIsCorrectlyMapped() {
630643

631644
@Test
632645
void oracleSqlplusWarnIsCorrectlyMapped() {
646+
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
647+
.withPropertyValues("spring.flyway.oracle.sqlplus-warn=true")
648+
.run((context) -> assertThat(context.getBean(Flyway.class)
649+
.getConfiguration()
650+
.getPluginRegister()
651+
.getPlugin(OracleConfigurationExtension.class)
652+
.getSqlplusWarn()).isTrue());
653+
}
654+
655+
@Test
656+
@Deprecated(since = "3.2.0", forRemoval = true)
657+
void oracleSqlplusWarnIsCorrectlyMappedWithDeprecatedProperty() {
633658
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
634659
.withPropertyValues("spring.flyway.oracle-sqlplus-warn=true")
635660
.run((context) -> assertThat(context.getBean(Flyway.class)
@@ -641,6 +666,18 @@ void oracleSqlplusWarnIsCorrectlyMapped() {
641666

642667
@Test
643668
void oracleWallerLocationIsCorrectlyMapped() {
669+
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
670+
.withPropertyValues("spring.flyway.oracle.wallet-location=/tmp/my.wallet")
671+
.run((context) -> assertThat(context.getBean(Flyway.class)
672+
.getConfiguration()
673+
.getPluginRegister()
674+
.getPlugin(OracleConfigurationExtension.class)
675+
.getWalletLocation()).isEqualTo("/tmp/my.wallet"));
676+
}
677+
678+
@Test
679+
@Deprecated(since = "3.2.0", forRemoval = true)
680+
void oracleWallerLocationIsCorrectlyMappedWithDeprecatedProperty() {
644681
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
645682
.withPropertyValues("spring.flyway.oracle-wallet-location=/tmp/my.wallet")
646683
.run((context) -> assertThat(context.getBean(Flyway.class)
@@ -652,6 +689,18 @@ void oracleWallerLocationIsCorrectlyMapped() {
652689

653690
@Test
654691
void oracleKerberosCacheFileIsCorrectlyMapped() {
692+
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
693+
.withPropertyValues("spring.flyway.oracle.kerberos-cache-file=/tmp/cache")
694+
.run((context) -> assertThat(context.getBean(Flyway.class)
695+
.getConfiguration()
696+
.getPluginRegister()
697+
.getPlugin(OracleConfigurationExtension.class)
698+
.getKerberosCacheFile()).isEqualTo("/tmp/cache"));
699+
}
700+
701+
@Test
702+
@Deprecated(since = "3.2.0", forRemoval = true)
703+
void oracleKerberosCacheFileIsCorrectlyMappedWithDeprecatedProperty() {
655704
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
656705
.withPropertyValues("spring.flyway.oracle-kerberos-cache-file=/tmp/cache")
657706
.run((context) -> assertThat(context.getBean(Flyway.class)
@@ -762,6 +811,20 @@ void sqlServerExtensionIsNotLoadedByDefault() {
762811

763812
@Test
764813
void sqlServerKerberosLoginFileIsCorrectlyMapped() {
814+
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
815+
.withPropertyValues("spring.flyway.sqlserver.kerberos-login-file=/tmp/config")
816+
.run((context) -> assertThat(context.getBean(Flyway.class)
817+
.getConfiguration()
818+
.getPluginRegister()
819+
.getPlugin(SQLServerConfigurationExtension.class)
820+
.getKerberos()
821+
.getLogin()
822+
.getFile()).isEqualTo("/tmp/config"));
823+
}
824+
825+
@Test
826+
@Deprecated(since = "3.2.0", forRemoval = true)
827+
void sqlServerKerberosLoginFileIsCorrectlyMappedWithDeprecatedProperty() {
765828
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
766829
.withPropertyValues("spring.flyway.sql-server-kerberos-login-file=/tmp/config")
767830
.run((context) -> assertThat(context.getBean(Flyway.class)

0 commit comments

Comments
 (0)