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
This commit is contained in:
Jacques-Etienne Beaudet 2016-01-19 12:55:39 -05:00 committed by Stephane Nicoll
parent 5ef6903690
commit a749855cb5
3 changed files with 6 additions and 3 deletions

View File

@ -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;
}

View File

@ -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 {
/**
* 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.

View File

@ -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);