mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Allow remote restart to work with nested JARs
Update remote restart support so that JARs multi-module projects work. Fixes gh-4040
This commit is contained in:
parent
e79ef9b73b
commit
5150e051c0
@ -204,7 +204,7 @@ public class Restarter {
|
||||
*/
|
||||
public void addUrls(Collection<URL> urls) {
|
||||
Assert.notNull(urls, "Urls must not be null");
|
||||
this.urls.addAll(ChangeableUrls.fromUrls(urls).toList());
|
||||
this.urls.addAll(urls);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,9 @@
|
||||
package org.springframework.boot.devtools.restart.server;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -38,6 +41,11 @@ public class DefaultSourceFolderUrlFilter implements SourceFolderUrlFilter {
|
||||
private static final Pattern VERSION_PATTERN = Pattern
|
||||
.compile("^-\\d+(?:\\.\\d+)*(?:[.-].+)?$");
|
||||
|
||||
private static final Set<String> SKIPPED_PROJECTS = new HashSet<String>(
|
||||
Arrays.asList("spring-boot", "spring-boot-devtools",
|
||||
"spring-boot-autoconfigure", "spring-boot-actuator",
|
||||
"spring-boot-starter"));
|
||||
|
||||
@Override
|
||||
public boolean isMatch(String sourceFolder, URL url) {
|
||||
String jarName = getJarName(url);
|
||||
@ -68,7 +76,7 @@ public class DefaultSourceFolderUrlFilter implements SourceFolderUrlFilter {
|
||||
}
|
||||
|
||||
private boolean isFolderMatch(String folder, String jarName) {
|
||||
if (!jarName.startsWith(folder)) {
|
||||
if (!jarName.startsWith(folder) || SKIPPED_PROJECTS.contains(folder)) {
|
||||
return false;
|
||||
}
|
||||
String version = jarName.substring(folder.length());
|
||||
|
@ -70,6 +70,22 @@ public class DefaultSourceFolderUrlFilterTests {
|
||||
doTest("my-module/something/quite/quite/mad/");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skippedProjects() throws Exception {
|
||||
String sourceFolder = "/Users/me/code/spring-boot-samples/"
|
||||
+ "spring-boot-sample-devtools";
|
||||
URL jarUrl = new URL("jar:file:/Users/me/tmp/"
|
||||
+ "spring-boot-sample-devtools-1.3.0.BUILD-SNAPSHOT.jar!/");
|
||||
assertThat(this.filter.isMatch(sourceFolder, jarUrl), equalTo(true));
|
||||
URL nestedJarUrl = new URL("jar:file:/Users/me/tmp/"
|
||||
+ "spring-boot-sample-devtools-1.3.0.BUILD-SNAPSHOT.jar!/"
|
||||
+ "lib/spring-boot-1.3.0.BUILD-SNAPSHOT.jar!/");
|
||||
assertThat(this.filter.isMatch(sourceFolder, nestedJarUrl), equalTo(false));
|
||||
URL fileUrl = new URL("file:/Users/me/tmp/"
|
||||
+ "spring-boot-sample-devtools-1.3.0.BUILD-SNAPSHOT.jar");
|
||||
assertThat(this.filter.isMatch(sourceFolder, fileUrl), equalTo(true));
|
||||
}
|
||||
|
||||
private void doTest(String sourcePostfix) throws MalformedURLException {
|
||||
doTest(sourcePostfix, "my-module", true);
|
||||
doTest(sourcePostfix, "my-module-other", false);
|
||||
|
Loading…
Reference in New Issue
Block a user