Make dev tools' home directory configurable
This allows separate projects to keep their own settings where common settings such as spring.* or server.* don't conflict. See gh-17924
This commit is contained in:
committed by
Andy Wilkinson
parent
48db35bf8d
commit
b9dbfad473
@@ -47,9 +47,12 @@ class DevToolsHomePropertiesPostProcessorTests {
|
||||
|
||||
private File home;
|
||||
|
||||
private File rootDir;
|
||||
|
||||
@BeforeEach
|
||||
void setup(@TempDir File tempDir) {
|
||||
void setup(@TempDir File tempDir, @TempDir File rootDir) {
|
||||
this.home = tempDir;
|
||||
this.rootDir = rootDir;
|
||||
this.configDir = this.home + "/.config/spring-boot/";
|
||||
new File(this.configDir).mkdirs();
|
||||
}
|
||||
@@ -63,6 +66,21 @@ class DevToolsHomePropertiesPostProcessorTests {
|
||||
assertThat(environment.getProperty("abc")).isEqualTo("def");
|
||||
}
|
||||
|
||||
@Test
|
||||
void loadsRootFolderProperties() throws Exception {
|
||||
System.setProperty("PROJECT_ROOT_FOLDER", this.rootDir.getAbsolutePath());
|
||||
Properties properties = new Properties();
|
||||
properties.put("uvw", "xyz");
|
||||
OutputStream out = new FileOutputStream(
|
||||
new File(this.rootDir, ".config/spring-boot/spring-boot-devtools.properties"));
|
||||
properties.store(out, null);
|
||||
out.close();
|
||||
ConfigurableEnvironment environment = new MockEnvironment();
|
||||
MockDevToolHomePropertiesPostProcessor postProcessor = new MockDevToolHomePropertiesPostProcessor();
|
||||
runPostProcessor(() -> postProcessor.postProcessEnvironment(environment, null));
|
||||
assertThat(environment.getProperty("uvw")).isEqualTo("xyz");
|
||||
}
|
||||
|
||||
@Test
|
||||
void loadsPropertiesFromConfigDirectoryUsingProperties() throws Exception {
|
||||
Properties properties = new Properties();
|
||||
|
||||
Reference in New Issue
Block a user