|
|
|
@ -161,106 +161,117 @@ public class FlywayAutoConfiguration { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Configure the given {@code configuration} using the given {@code properties}. |
|
|
|
|
|
|
|
* <p> |
|
|
|
|
|
|
|
* To maximize forwards- and backwards-compatibility method references are not |
|
|
|
|
|
|
|
* used. |
|
|
|
|
|
|
|
* @param configuration the configuration |
|
|
|
|
|
|
|
* @param properties the properties |
|
|
|
|
|
|
|
*/ |
|
|
|
private void configureProperties(FluentConfiguration configuration, FlywayProperties properties) { |
|
|
|
private void configureProperties(FluentConfiguration configuration, FlywayProperties properties) { |
|
|
|
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); |
|
|
|
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); |
|
|
|
|
|
|
|
configureFailOnMissingLocations(configuration, properties.isFailOnMissingLocations()); |
|
|
|
String[] locations = new LocationResolver(configuration.getDataSource()) |
|
|
|
String[] locations = new LocationResolver(configuration.getDataSource()) |
|
|
|
.resolveLocations(properties.getLocations()) |
|
|
|
.resolveLocations(properties.getLocations()) |
|
|
|
.toArray(new String[0]); |
|
|
|
.toArray(new String[0]); |
|
|
|
configureFailOnMissingLocations(configuration, properties.isFailOnMissingLocations()); |
|
|
|
configuration.locations(locations); |
|
|
|
map.from(locations).to(configuration::locations); |
|
|
|
map.from(properties.getEncoding()).to((encoding) -> configuration.encoding(encoding)); |
|
|
|
map.from(properties.getEncoding()).to(configuration::encoding); |
|
|
|
map.from(properties.getConnectRetries()) |
|
|
|
map.from(properties.getConnectRetries()).to(configuration::connectRetries); |
|
|
|
.to((connectRetries) -> configuration.connectRetries(connectRetries)); |
|
|
|
// No method reference for compatibility with Flyway < 7.15
|
|
|
|
|
|
|
|
map.from(properties.getConnectRetriesInterval()) |
|
|
|
map.from(properties.getConnectRetriesInterval()) |
|
|
|
.to((interval) -> configuration.connectRetriesInterval((int) interval.getSeconds())); |
|
|
|
.to((interval) -> configuration.connectRetriesInterval((int) interval.getSeconds())); |
|
|
|
// No method reference for compatibility with Flyway 6.x
|
|
|
|
|
|
|
|
map.from(properties.getLockRetryCount()) |
|
|
|
map.from(properties.getLockRetryCount()) |
|
|
|
.to((lockRetryCount) -> configuration.lockRetryCount(lockRetryCount)); |
|
|
|
.to((lockRetryCount) -> configuration.lockRetryCount(lockRetryCount)); |
|
|
|
// No method reference for compatibility with Flyway 5.x
|
|
|
|
|
|
|
|
map.from(properties.getDefaultSchema()).to((schema) -> configuration.defaultSchema(schema)); |
|
|
|
map.from(properties.getDefaultSchema()).to((schema) -> configuration.defaultSchema(schema)); |
|
|
|
map.from(properties.getSchemas()).as(StringUtils::toStringArray).to(configuration::schemas); |
|
|
|
map.from(properties.getSchemas()) |
|
|
|
|
|
|
|
.as(StringUtils::toStringArray) |
|
|
|
|
|
|
|
.to((schemas) -> configuration.schemas(schemas)); |
|
|
|
configureCreateSchemas(configuration, properties.isCreateSchemas()); |
|
|
|
configureCreateSchemas(configuration, properties.isCreateSchemas()); |
|
|
|
map.from(properties.getTable()).to(configuration::table); |
|
|
|
map.from(properties.getTable()).to((table) -> configuration.table(table)); |
|
|
|
// No method reference for compatibility with Flyway 5.x
|
|
|
|
|
|
|
|
map.from(properties.getTablespace()).to((tablespace) -> configuration.tablespace(tablespace)); |
|
|
|
map.from(properties.getTablespace()).to((tablespace) -> configuration.tablespace(tablespace)); |
|
|
|
map.from(properties.getBaselineDescription()).to(configuration::baselineDescription); |
|
|
|
map.from(properties.getBaselineDescription()) |
|
|
|
map.from(properties.getBaselineVersion()).to(configuration::baselineVersion); |
|
|
|
.to((baselineDescription) -> configuration.baselineDescription(baselineDescription)); |
|
|
|
map.from(properties.getInstalledBy()).to(configuration::installedBy); |
|
|
|
map.from(properties.getBaselineVersion()) |
|
|
|
map.from(properties.getPlaceholders()).to(configuration::placeholders); |
|
|
|
.to((baselineVersion) -> configuration.baselineVersion(baselineVersion)); |
|
|
|
map.from(properties.getPlaceholderPrefix()).to(configuration::placeholderPrefix); |
|
|
|
map.from(properties.getInstalledBy()).to((installedBy) -> configuration.installedBy(installedBy)); |
|
|
|
map.from(properties.getPlaceholderSuffix()).to(configuration::placeholderSuffix); |
|
|
|
map.from(properties.getPlaceholders()).to((placeholders) -> configuration.placeholders(placeholders)); |
|
|
|
// No method reference for compatibility with Flyway version < 8.0
|
|
|
|
map.from(properties.getPlaceholderPrefix()) |
|
|
|
|
|
|
|
.to((placeholderPrefix) -> configuration.placeholderPrefix(placeholderPrefix)); |
|
|
|
|
|
|
|
map.from(properties.getPlaceholderSuffix()) |
|
|
|
|
|
|
|
.to((placeholderSuffix) -> configuration.placeholderSuffix(placeholderSuffix)); |
|
|
|
map.from(properties.getPlaceholderSeparator()) |
|
|
|
map.from(properties.getPlaceholderSeparator()) |
|
|
|
.to((placeHolderSeparator) -> configuration.placeholderSeparator(placeHolderSeparator)); |
|
|
|
.to((placeHolderSeparator) -> configuration.placeholderSeparator(placeHolderSeparator)); |
|
|
|
map.from(properties.isPlaceholderReplacement()).to(configuration::placeholderReplacement); |
|
|
|
map.from(properties.isPlaceholderReplacement()) |
|
|
|
map.from(properties.getSqlMigrationPrefix()).to(configuration::sqlMigrationPrefix); |
|
|
|
.to((placeholderReplacement) -> configuration.placeholderReplacement(placeholderReplacement)); |
|
|
|
|
|
|
|
map.from(properties.getSqlMigrationPrefix()) |
|
|
|
|
|
|
|
.to((sqlMigrationPrefix) -> configuration.sqlMigrationPrefix(sqlMigrationPrefix)); |
|
|
|
map.from(properties.getSqlMigrationSuffixes()) |
|
|
|
map.from(properties.getSqlMigrationSuffixes()) |
|
|
|
.as(StringUtils::toStringArray) |
|
|
|
.as(StringUtils::toStringArray) |
|
|
|
.to(configuration::sqlMigrationSuffixes); |
|
|
|
.to((sqlMigrationSuffixes) -> configuration.sqlMigrationSuffixes(sqlMigrationSuffixes)); |
|
|
|
map.from(properties.getSqlMigrationSeparator()).to(configuration::sqlMigrationSeparator); |
|
|
|
map.from(properties.getSqlMigrationSeparator()) |
|
|
|
map.from(properties.getRepeatableSqlMigrationPrefix()).to(configuration::repeatableSqlMigrationPrefix); |
|
|
|
.to((sqlMigrationSeparator) -> configuration.sqlMigrationSeparator(sqlMigrationSeparator)); |
|
|
|
map.from(properties.getTarget()).to(configuration::target); |
|
|
|
map.from(properties.getRepeatableSqlMigrationPrefix()) |
|
|
|
map.from(properties.isBaselineOnMigrate()).to(configuration::baselineOnMigrate); |
|
|
|
.to((repeatableSqlMigrationPrefix) -> configuration |
|
|
|
map.from(properties.isCleanDisabled()).to(configuration::cleanDisabled); |
|
|
|
.repeatableSqlMigrationPrefix(repeatableSqlMigrationPrefix)); |
|
|
|
map.from(properties.isCleanOnValidationError()).to(configuration::cleanOnValidationError); |
|
|
|
map.from(properties.getTarget()).to((target) -> configuration.target(target)); |
|
|
|
map.from(properties.isGroup()).to(configuration::group); |
|
|
|
map.from(properties.isBaselineOnMigrate()) |
|
|
|
|
|
|
|
.to((baselineOnMigrate) -> configuration.baselineOnMigrate(baselineOnMigrate)); |
|
|
|
|
|
|
|
map.from(properties.isCleanDisabled()).to((cleanDisabled) -> configuration.cleanDisabled(cleanDisabled)); |
|
|
|
|
|
|
|
map.from(properties.isCleanOnValidationError()) |
|
|
|
|
|
|
|
.to((cleanOnValidationError) -> configuration.cleanOnValidationError(cleanOnValidationError)); |
|
|
|
|
|
|
|
map.from(properties.isGroup()).to((group) -> configuration.group(group)); |
|
|
|
configureIgnoredMigrations(configuration, properties, map); |
|
|
|
configureIgnoredMigrations(configuration, properties, map); |
|
|
|
map.from(properties.isMixed()).to(configuration::mixed); |
|
|
|
map.from(properties.isMixed()).to((mixed) -> configuration.mixed(mixed)); |
|
|
|
map.from(properties.isOutOfOrder()).to(configuration::outOfOrder); |
|
|
|
map.from(properties.isOutOfOrder()).to((outOfOrder) -> configuration.outOfOrder(outOfOrder)); |
|
|
|
map.from(properties.isSkipDefaultCallbacks()).to(configuration::skipDefaultCallbacks); |
|
|
|
map.from(properties.isSkipDefaultCallbacks()) |
|
|
|
map.from(properties.isSkipDefaultResolvers()).to(configuration::skipDefaultResolvers); |
|
|
|
.to((skipDefaultCallbacks) -> configuration.skipDefaultCallbacks(skipDefaultCallbacks)); |
|
|
|
|
|
|
|
map.from(properties.isSkipDefaultResolvers()) |
|
|
|
|
|
|
|
.to((skipDefaultResolvers) -> configuration.skipDefaultResolvers(skipDefaultResolvers)); |
|
|
|
configureValidateMigrationNaming(configuration, properties.isValidateMigrationNaming()); |
|
|
|
configureValidateMigrationNaming(configuration, properties.isValidateMigrationNaming()); |
|
|
|
map.from(properties.isValidateOnMigrate()).to(configuration::validateOnMigrate); |
|
|
|
map.from(properties.isValidateOnMigrate()) |
|
|
|
|
|
|
|
.to((validateOnMigrate) -> configuration.validateOnMigrate(validateOnMigrate)); |
|
|
|
map.from(properties.getInitSqls()) |
|
|
|
map.from(properties.getInitSqls()) |
|
|
|
.whenNot(CollectionUtils::isEmpty) |
|
|
|
.whenNot(CollectionUtils::isEmpty) |
|
|
|
.as((initSqls) -> StringUtils.collectionToDelimitedString(initSqls, "\n")) |
|
|
|
.as((initSqls) -> StringUtils.collectionToDelimitedString(initSqls, "\n")) |
|
|
|
.to(configuration::initSql); |
|
|
|
.to((initSql) -> configuration.initSql(initSql)); |
|
|
|
map.from(properties.getScriptPlaceholderPrefix()) |
|
|
|
map.from(properties.getScriptPlaceholderPrefix()) |
|
|
|
.to((prefix) -> configuration.scriptPlaceholderPrefix(prefix)); |
|
|
|
.to((prefix) -> configuration.scriptPlaceholderPrefix(prefix)); |
|
|
|
map.from(properties.getScriptPlaceholderSuffix()) |
|
|
|
map.from(properties.getScriptPlaceholderSuffix()) |
|
|
|
.to((suffix) -> configuration.scriptPlaceholderSuffix(suffix)); |
|
|
|
.to((suffix) -> configuration.scriptPlaceholderSuffix(suffix)); |
|
|
|
// Pro properties
|
|
|
|
// Pro properties
|
|
|
|
map.from(properties.getBatch()).to(configuration::batch); |
|
|
|
map.from(properties.getBatch()).to((batch) -> configuration.batch(batch)); |
|
|
|
map.from(properties.getDryRunOutput()).to(configuration::dryRunOutput); |
|
|
|
map.from(properties.getDryRunOutput()).to((dryRunOutput) -> configuration.dryRunOutput(dryRunOutput)); |
|
|
|
map.from(properties.getErrorOverrides()).to(configuration::errorOverrides); |
|
|
|
map.from(properties.getErrorOverrides()) |
|
|
|
map.from(properties.getLicenseKey()).to(configuration::licenseKey); |
|
|
|
.to((errorOverrides) -> configuration.errorOverrides(errorOverrides)); |
|
|
|
// No method reference for compatibility with Flyway 9.20+
|
|
|
|
map.from(properties.getLicenseKey()).to((licenseKey) -> configuration.licenseKey(licenseKey)); |
|
|
|
map.from(properties.getOracleSqlplus()).to((oracleSqlplus) -> configuration.oracleSqlplus(oracleSqlplus)); |
|
|
|
map.from(properties.getOracleSqlplus()).to((oracleSqlplus) -> configuration.oracleSqlplus(oracleSqlplus)); |
|
|
|
// No method reference for compatibility with Flyway 5.x
|
|
|
|
|
|
|
|
map.from(properties.getOracleSqlplusWarn()) |
|
|
|
map.from(properties.getOracleSqlplusWarn()) |
|
|
|
.to((oracleSqlplusWarn) -> configuration.oracleSqlplusWarn(oracleSqlplusWarn)); |
|
|
|
.to((oracleSqlplusWarn) -> configuration.oracleSqlplusWarn(oracleSqlplusWarn)); |
|
|
|
map.from(properties.getStream()).to(configuration::stream); |
|
|
|
map.from(properties.getStream()).to((stream) -> configuration.stream(stream)); |
|
|
|
map.from(properties.getUndoSqlMigrationPrefix()).to(configuration::undoSqlMigrationPrefix); |
|
|
|
map.from(properties.getUndoSqlMigrationPrefix()) |
|
|
|
// No method reference for compatibility with Flyway 6.x
|
|
|
|
.to((undoSqlMigrationPrefix) -> configuration.undoSqlMigrationPrefix(undoSqlMigrationPrefix)); |
|
|
|
map.from(properties.getCherryPick()).to((cherryPick) -> configuration.cherryPick(cherryPick)); |
|
|
|
map.from(properties.getCherryPick()).to((cherryPick) -> configuration.cherryPick(cherryPick)); |
|
|
|
// No method reference for compatibility with Flyway 6.x
|
|
|
|
|
|
|
|
map.from(properties.getJdbcProperties()) |
|
|
|
map.from(properties.getJdbcProperties()) |
|
|
|
.whenNot(Map::isEmpty) |
|
|
|
.whenNot(Map::isEmpty) |
|
|
|
.to((jdbcProperties) -> configuration.jdbcProperties(jdbcProperties)); |
|
|
|
.to((jdbcProperties) -> configuration.jdbcProperties(jdbcProperties)); |
|
|
|
// No method reference for compatibility with Flyway 6.x
|
|
|
|
|
|
|
|
map.from(properties.getKerberosConfigFile()) |
|
|
|
map.from(properties.getKerberosConfigFile()) |
|
|
|
.to((configFile) -> configuration.kerberosConfigFile(configFile)); |
|
|
|
.to((configFile) -> configuration.kerberosConfigFile(configFile)); |
|
|
|
// No method reference for compatibility with Flyway 6.x
|
|
|
|
|
|
|
|
map.from(properties.getOracleKerberosCacheFile()) |
|
|
|
map.from(properties.getOracleKerberosCacheFile()) |
|
|
|
.to((cacheFile) -> configuration.oracleKerberosCacheFile(cacheFile)); |
|
|
|
.to((cacheFile) -> configuration.oracleKerberosCacheFile(cacheFile)); |
|
|
|
// No method reference for compatibility with Flyway 6.x
|
|
|
|
|
|
|
|
map.from(properties.getOutputQueryResults()) |
|
|
|
map.from(properties.getOutputQueryResults()) |
|
|
|
.to((outputQueryResults) -> configuration.outputQueryResults(outputQueryResults)); |
|
|
|
.to((outputQueryResults) -> configuration.outputQueryResults(outputQueryResults)); |
|
|
|
map.from(properties.getSqlServerKerberosLoginFile()) |
|
|
|
map.from(properties.getSqlServerKerberosLoginFile()) |
|
|
|
.whenNonNull() |
|
|
|
.whenNonNull() |
|
|
|
.to(this::configureSqlServerKerberosLoginFile); |
|
|
|
.to(this::configureSqlServerKerberosLoginFile); |
|
|
|
// No method reference for compatibility with Flyway 6.x
|
|
|
|
|
|
|
|
map.from(properties.getSkipExecutingMigrations()) |
|
|
|
map.from(properties.getSkipExecutingMigrations()) |
|
|
|
.to((skipExecutingMigrations) -> configuration.skipExecutingMigrations(skipExecutingMigrations)); |
|
|
|
.to((skipExecutingMigrations) -> configuration.skipExecutingMigrations(skipExecutingMigrations)); |
|
|
|
// No method reference for compatibility with Flyway < 7.8
|
|
|
|
|
|
|
|
map.from(properties.getIgnoreMigrationPatterns()) |
|
|
|
map.from(properties.getIgnoreMigrationPatterns()) |
|
|
|
.whenNot(List::isEmpty) |
|
|
|
.whenNot(List::isEmpty) |
|
|
|
.to((ignoreMigrationPatterns) -> configuration |
|
|
|
.to((ignoreMigrationPatterns) -> configuration |
|
|
|
.ignoreMigrationPatterns(ignoreMigrationPatterns.toArray(new String[0]))); |
|
|
|
.ignoreMigrationPatterns(ignoreMigrationPatterns.toArray(new String[0]))); |
|
|
|
// No method reference for compatibility with Flyway version < 7.9
|
|
|
|
|
|
|
|
map.from(properties.getDetectEncoding()) |
|
|
|
map.from(properties.getDetectEncoding()) |
|
|
|
.to((detectEncoding) -> configuration.detectEncoding(detectEncoding)); |
|
|
|
.to((detectEncoding) -> configuration.detectEncoding(detectEncoding)); |
|
|
|
// No method reference for compatibility with Flyway version < 8.0
|
|
|
|
|
|
|
|
map.from(properties.getBaselineMigrationPrefix()) |
|
|
|
map.from(properties.getBaselineMigrationPrefix()) |
|
|
|
.to((baselineMigrationPrefix) -> configuration.baselineMigrationPrefix(baselineMigrationPrefix)); |
|
|
|
.to((baselineMigrationPrefix) -> configuration.baselineMigrationPrefix(baselineMigrationPrefix)); |
|
|
|
} |
|
|
|
} |
|
|
|
|