Browse Source

Allow indexed access of `flyway.locations`

This commit allows to use the `flyway.locations` in an indexed fashion
(i.e. typically in YAML configuration).

See gh-4973
1.2.x
Jacques-Etienne Beaudet 10 years ago committed by Stephane Nicoll
parent
commit
a749855cb5
  1. 2
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java
  2. 3
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java
  3. 4
      spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java

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

@ -114,6 +114,8 @@ public class FlywayAutoConfiguration { @@ -114,6 +114,8 @@ public class FlywayAutoConfiguration {
else {
flyway.setDataSource(this.dataSource);
}
//Explicitly set locations because the getter doesn't return a mutable value
flyway.setLocations(this.properties.getLocations().toArray(new String[0]));
return flyway;
}

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

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.flyway;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@ -39,7 +40,7 @@ public class FlywayProperties { @@ -39,7 +40,7 @@ public class FlywayProperties {
/**
* Locations of migrations scripts.
*/
private List<String> locations = Arrays.asList("db/migration");
private List<String> locations = new ArrayList<String>(Arrays.asList("db/migration"));
/**
* Check that migration scripts location exists.

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

@ -104,8 +104,8 @@ public class FlywayAutoConfigurationTests { @@ -104,8 +104,8 @@ public class FlywayAutoConfigurationTests {
@Test
public void overrideLocations() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context,
"flyway.locations:classpath:db/changelog,classpath:db/migration");
EnvironmentTestUtils.addEnvironment(this.context, "flyway.locations[0]:classpath:db/changelog",
"flyway.locations[1]:classpath:db/migration");
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
FlywayAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);

Loading…
Cancel
Save