Merge branch '1.5.x'

pull/8063/head
Andy Wilkinson 8 years ago
commit d7ea15a95d

@ -393,8 +393,11 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
}
// Any pre-existing active profiles set via property sources (e.g. System
// properties) take precedence over those added in config files.
Set<Profile> activeProfiles = bindSpringProfiles(
this.environment.getPropertySources()).getActiveProfiles();
SpringProfiles springProfiles = bindSpringProfiles(
this.environment.getPropertySources());
Set<Profile> activeProfiles = new LinkedHashSet<Profile>(
springProfiles.getActiveProfiles());
activeProfiles.addAll(springProfiles.getIncludeProfiles());
maybeActivateProfiles(activeProfiles);
return activeProfiles;
}

@ -837,6 +837,18 @@ public class ConfigFileApplicationListenerTests {
assertThat(environment.acceptsProfiles("customdefault")).isTrue();
}
@Test
public void additionalProfilesCanBeIncludedFromAnyPropertySource() throws Exception {
SpringApplication application = new SpringApplication(Config.class);
application.setWebEnvironment(false);
this.context = application.run("--spring.profiles.active=myprofile",
"--spring.profiles.include=dev");
String property = this.context.getEnvironment().getProperty("my.property");
assertThat(property).isEqualTo("fromdevpropertiesfile");
assertThat(this.context.getEnvironment().containsProperty("customdefault"))
.isFalse();
}
private Condition<ConfigurableEnvironment> matchingPropertySource(
final String sourceName) {
return new Condition<ConfigurableEnvironment>(

Loading…
Cancel
Save