Allow additional paths that trigger a reload/restart to be configured
Previously, only folders on the classpath would be watched and used to trigger a restart/reload of the application. This commit adds a new property spring.devtools.restart.additional-paths that can be used to configure additional paths that should be watched for changes. When a change occurs in one of those paths a restart or reload will be triggered, depending on the full restart exclude patterns configured via the existing spring.devtools.restart.exclude property. Closes gh-3469
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
|
||||
package org.springframework.boot.devtools.autoconfigure;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
|
||||
@@ -87,6 +91,11 @@ public class DevToolsProperties {
|
||||
*/
|
||||
private String triggerFile;
|
||||
|
||||
/**
|
||||
* Additional paths to watch for changes.
|
||||
*/
|
||||
private List<File> additionalPaths = new ArrayList<File>();
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
@@ -127,6 +136,14 @@ public class DevToolsProperties {
|
||||
this.triggerFile = triggerFile;
|
||||
}
|
||||
|
||||
public List<File> getAdditionalPaths() {
|
||||
return this.additionalPaths;
|
||||
}
|
||||
|
||||
public void setAdditionalPaths(List<File> additionalPaths) {
|
||||
this.additionalPaths = additionalPaths;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
package org.springframework.boot.devtools.autoconfigure;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -158,6 +160,10 @@ public class LocalDevToolsAutoConfiguration {
|
||||
if (StringUtils.hasLength(triggerFile)) {
|
||||
watcher.setTriggerFilter(new TriggerFileFilter(triggerFile));
|
||||
}
|
||||
List<File> additionalPaths = restartProperties.getAdditionalPaths();
|
||||
for (File path : additionalPaths) {
|
||||
watcher.addSourceFolder(path.getAbsoluteFile());
|
||||
}
|
||||
return watcher;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user