17
17
package org .springframework .boot .autoconfigure .flyway ;
18
18
19
19
import java .sql .DatabaseMetaData ;
20
+ import java .time .Duration ;
20
21
import java .util .Collection ;
21
22
import java .util .Collections ;
22
23
import java .util .HashSet ;
@@ -164,32 +165,25 @@ private void configureProperties(FluentConfiguration configuration, FlywayProper
164
165
PropertyMapper map = PropertyMapper .get ().alwaysApplyingWhenNonNull ();
165
166
String [] locations = new LocationResolver (configuration .getDataSource ())
166
167
.resolveLocations (properties .getLocations ()).toArray (new String [0 ]);
167
- configureFailOnMissingLocations ( configuration , properties .isFailOnMissingLocations ());
168
+ map . from ( properties .isFailOnMissingLocations ()). to ( configuration :: failOnMissingLocations );
168
169
map .from (locations ).to (configuration ::locations );
169
170
map .from (properties .getEncoding ()).to (configuration ::encoding );
170
171
map .from (properties .getConnectRetries ()).to (configuration ::connectRetries );
171
- // No method reference for compatibility with Flyway < 7.15
172
- map .from (properties .getConnectRetriesInterval ())
173
- .to ((interval ) -> configuration .connectRetriesInterval ((int ) interval .getSeconds ()));
174
- // No method reference for compatibility with Flyway 6.x
175
- map .from (properties .getLockRetryCount ())
176
- .to ((lockRetryCount ) -> configuration .lockRetryCount (lockRetryCount ));
177
- // No method reference for compatibility with Flyway 5.x
178
- map .from (properties .getDefaultSchema ()).to ((schema ) -> configuration .defaultSchema (schema ));
172
+ map .from (properties .getConnectRetriesInterval ()).as (Duration ::getSeconds ).as (Long ::intValue )
173
+ .to (configuration ::connectRetriesInterval );
174
+ map .from (properties .getLockRetryCount ()).to (configuration ::lockRetryCount );
175
+ map .from (properties .getDefaultSchema ()).to (configuration ::defaultSchema );
179
176
map .from (properties .getSchemas ()).as (StringUtils ::toStringArray ).to (configuration ::schemas );
180
- configureCreateSchemas ( configuration , properties .isCreateSchemas ());
177
+ map . from ( properties .isCreateSchemas ()). to ( configuration :: createSchemas );
181
178
map .from (properties .getTable ()).to (configuration ::table );
182
- // No method reference for compatibility with Flyway 5.x
183
- map .from (properties .getTablespace ()).to ((tablespace ) -> configuration .tablespace (tablespace ));
179
+ map .from (properties .getTablespace ()).to (configuration ::tablespace );
184
180
map .from (properties .getBaselineDescription ()).to (configuration ::baselineDescription );
185
181
map .from (properties .getBaselineVersion ()).to (configuration ::baselineVersion );
186
182
map .from (properties .getInstalledBy ()).to (configuration ::installedBy );
187
183
map .from (properties .getPlaceholders ()).to (configuration ::placeholders );
188
184
map .from (properties .getPlaceholderPrefix ()).to (configuration ::placeholderPrefix );
189
185
map .from (properties .getPlaceholderSuffix ()).to (configuration ::placeholderSuffix );
190
- // No method reference for compatibility with Flyway version < 8.0
191
- map .from (properties .getPlaceholderSeparator ())
192
- .to ((placeHolderSeparator ) -> configuration .placeholderSeparator (placeHolderSeparator ));
186
+ map .from (properties .getPlaceholderSeparator ()).to (configuration ::placeholderSeparator );
193
187
map .from (properties .isPlaceholderReplacement ()).to (configuration ::placeholderReplacement );
194
188
map .from (properties .getSqlMigrationPrefix ()).to (configuration ::sqlMigrationPrefix );
195
189
map .from (properties .getSqlMigrationSuffixes ()).as (StringUtils ::toStringArray )
@@ -205,7 +199,7 @@ private void configureProperties(FluentConfiguration configuration, FlywayProper
205
199
map .from (properties .isOutOfOrder ()).to (configuration ::outOfOrder );
206
200
map .from (properties .isSkipDefaultCallbacks ()).to (configuration ::skipDefaultCallbacks );
207
201
map .from (properties .isSkipDefaultResolvers ()).to (configuration ::skipDefaultResolvers );
208
- configureValidateMigrationNaming ( configuration , properties .isValidateMigrationNaming ());
202
+ map . from ( properties .isValidateMigrationNaming ()). to ( configuration :: validateMigrationNaming );
209
203
map .from (properties .isValidateOnMigrate ()).to (configuration ::validateOnMigrate );
210
204
map .from (properties .getInitSqls ()).whenNot (CollectionUtils ::isEmpty )
211
205
.as ((initSqls ) -> StringUtils .collectionToDelimitedString (initSqls , "\n " ))
@@ -214,63 +208,27 @@ private void configureProperties(FluentConfiguration configuration, FlywayProper
214
208
.to ((prefix ) -> configuration .scriptPlaceholderPrefix (prefix ));
215
209
map .from (properties .getScriptPlaceholderSuffix ())
216
210
.to ((suffix ) -> configuration .scriptPlaceholderSuffix (suffix ));
217
- // Pro properties
211
+ // Flyway Teams properties
218
212
map .from (properties .getBatch ()).to (configuration ::batch );
219
213
map .from (properties .getDryRunOutput ()).to (configuration ::dryRunOutput );
220
214
map .from (properties .getErrorOverrides ()).to (configuration ::errorOverrides );
221
215
map .from (properties .getLicenseKey ()).to (configuration ::licenseKey );
222
216
map .from (properties .getOracleSqlplus ()).to (configuration ::oracleSqlplus );
223
- // No method reference for compatibility with Flyway 5.x
224
- map .from (properties .getOracleSqlplusWarn ())
225
- .to ((oracleSqlplusWarn ) -> configuration .oracleSqlplusWarn (oracleSqlplusWarn ));
217
+ map .from (properties .getOracleSqlplusWarn ()).to (configuration ::oracleSqlplusWarn );
226
218
map .from (properties .getStream ()).to (configuration ::stream );
227
219
map .from (properties .getUndoSqlMigrationPrefix ()).to (configuration ::undoSqlMigrationPrefix );
228
- // No method reference for compatibility with Flyway 6.x
229
- map .from (properties .getCherryPick ()).to ((cherryPick ) -> configuration .cherryPick (cherryPick ));
230
- // No method reference for compatibility with Flyway 6.x
231
- map .from (properties .getJdbcProperties ()).whenNot (Map ::isEmpty )
232
- .to ((jdbcProperties ) -> configuration .jdbcProperties (jdbcProperties ));
233
- // No method reference for compatibility with Flyway 6.x
234
- map .from (properties .getKerberosConfigFile ())
235
- .to ((configFile ) -> configuration .kerberosConfigFile (configFile ));
236
- // No method reference for compatibility with Flyway 6.x
237
- map .from (properties .getOracleKerberosCacheFile ())
238
- .to ((cacheFile ) -> configuration .oracleKerberosCacheFile (cacheFile ));
239
- // No method reference for compatibility with Flyway 6.x
240
- map .from (properties .getOutputQueryResults ())
241
- .to ((outputQueryResults ) -> configuration .outputQueryResults (outputQueryResults ));
220
+ map .from (properties .getCherryPick ()).to (configuration ::cherryPick );
221
+ map .from (properties .getJdbcProperties ()).whenNot (Map ::isEmpty ).to (configuration ::jdbcProperties );
222
+ map .from (properties .getKerberosConfigFile ()).to (configuration ::kerberosConfigFile );
223
+ map .from (properties .getOracleKerberosCacheFile ()).to (configuration ::oracleKerberosCacheFile );
224
+ map .from (properties .getOutputQueryResults ()).to (configuration ::outputQueryResults );
242
225
map .from (properties .getSqlServerKerberosLoginFile ()).whenNonNull ()
243
226
.to ((sqlServerKerberosLoginFile ) -> configureSqlServerKerberosLoginFile (configuration ,
244
227
sqlServerKerberosLoginFile ));
245
- // No method reference for compatibility with Flyway 6.x
246
- map .from (properties .getSkipExecutingMigrations ())
247
- .to ((skipExecutingMigrations ) -> configuration .skipExecutingMigrations (skipExecutingMigrations ));
248
- // No method reference for compatibility with Flyway < 7.8
228
+ map .from (properties .getSkipExecutingMigrations ()).to (configuration ::skipExecutingMigrations );
249
229
map .from (properties .getIgnoreMigrationPatterns ()).whenNot (List ::isEmpty )
250
- .to ((ignoreMigrationPatterns ) -> configuration
251
- .ignoreMigrationPatterns (ignoreMigrationPatterns .toArray (new String [0 ])));
252
- // No method reference for compatibility with Flyway version < 7.9
253
- map .from (properties .getDetectEncoding ())
254
- .to ((detectEncoding ) -> configuration .detectEncoding (detectEncoding ));
255
- }
256
-
257
- private void configureFailOnMissingLocations (FluentConfiguration configuration ,
258
- boolean failOnMissingLocations ) {
259
- try {
260
- configuration .failOnMissingLocations (failOnMissingLocations );
261
- }
262
- catch (NoSuchMethodError ex ) {
263
- // Flyway < 7.9
264
- }
265
- }
266
-
267
- private void configureCreateSchemas (FluentConfiguration configuration , boolean createSchemas ) {
268
- try {
269
- configuration .createSchemas (createSchemas );
270
- }
271
- catch (NoSuchMethodError ex ) {
272
- // Flyway < 6.5
273
- }
230
+ .as ((patterns ) -> patterns .toArray (new String [0 ])).to (configuration ::ignoreMigrationPatterns );
231
+ map .from (properties .getDetectEncoding ()).to (configuration ::detectEncoding );
274
232
}
275
233
276
234
private void configureSqlServerKerberosLoginFile (FluentConfiguration configuration ,
@@ -281,16 +239,6 @@ private void configureSqlServerKerberosLoginFile(FluentConfiguration configurati
281
239
sqlServerConfigurationExtension .setKerberosLoginFile (sqlServerKerberosLoginFile );
282
240
}
283
241
284
- private void configureValidateMigrationNaming (FluentConfiguration configuration ,
285
- boolean validateMigrationNaming ) {
286
- try {
287
- configuration .validateMigrationNaming (validateMigrationNaming );
288
- }
289
- catch (NoSuchMethodError ex ) {
290
- // Flyway < 6.2
291
- }
292
- }
293
-
294
242
private void configureCallbacks (FluentConfiguration configuration , List <Callback > callbacks ) {
295
243
if (!callbacks .isEmpty ()) {
296
244
configuration .callbacks (callbacks .toArray (new Callback [0 ]));
@@ -305,12 +253,7 @@ private void configureFlywayCallbacks(FluentConfiguration flyway, List<Callback>
305
253
306
254
private void configureJavaMigrations (FluentConfiguration flyway , List <JavaMigration > migrations ) {
307
255
if (!migrations .isEmpty ()) {
308
- try {
309
- flyway .javaMigrations (migrations .toArray (new JavaMigration [0 ]));
310
- }
311
- catch (NoSuchMethodError ex ) {
312
- // Flyway 5.x
313
- }
256
+ flyway .javaMigrations (migrations .toArray (new JavaMigration [0 ]));
314
257
}
315
258
}
316
259
0 commit comments