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
@@ -93,7 +93,7 @@ public class DevToolsHomePropertiesPostProcessor implements EnvironmentPostProce
|
||||
|
||||
private void addPropertySource(List<PropertySource<?>> propertySources, String fileName,
|
||||
Function<File, String> propertySourceNamer) {
|
||||
File home = getHomeDirectory();
|
||||
File home = getProjectRootFolder();
|
||||
File file = (home != null) ? new File(home, fileName) : null;
|
||||
FileSystemResource resource = (file != null) ? new FileSystemResource(file) : null;
|
||||
if (resource != null && resource.exists() && resource.isFile()) {
|
||||
@@ -121,6 +121,17 @@ public class DevToolsHomePropertiesPostProcessor implements EnvironmentPostProce
|
||||
.anyMatch((fileExtension) -> StringUtils.endsWithIgnoreCase(name, fileExtension));
|
||||
}
|
||||
|
||||
protected File getProjectRootFolder() {
|
||||
String rootFolder = System.getenv("PROJECT_ROOT_FOLDER");
|
||||
if (rootFolder == null) {
|
||||
rootFolder = System.getProperty("PROJECT_ROOT_FOLDER");
|
||||
}
|
||||
if (StringUtils.hasLength(rootFolder)) {
|
||||
return new File(rootFolder);
|
||||
}
|
||||
return getHomeDirectory();
|
||||
}
|
||||
|
||||
protected File getHomeDirectory() {
|
||||
String home = System.getProperty("user.home");
|
||||
if (StringUtils.hasLength(home)) {
|
||||
|
||||
Reference in New Issue
Block a user