Prompted by https://github.com/spring-projects/spring-boot/issues/3315#issuecomment-683434499, I think we should review DevTools' restart excludes and make them more apparent at runtime.

The current defaults are a little odd as they're tailored towards Spring Boot's development, ignoring …/target/classes in 2.2.x which is built with Maven and …/build in 2.3.x which is built with Gradle. The behaviour that users see shouldn't be affected by the build system used to build Boot itself so it feels like we should either remove these default excludes or alter them so that they don't only apply to a particular build system.

When excludes have been applied – particularly when they leave you with no changeable URLs, and, therefore, no restart – it's not obvious that's what has happened. We should look at improving the logging somehow to help users to identify why changes to their application are having no effect.

Comment From: philwebb

See #4040

Comment From: wilkinsona

I'm not sure that I understand DefaultSourceDirectoryUrlFilterTests#skippedProjects as it still passes when SKIPPED_PROJECTS has been removed from DefaultSourceDirectoryUrlFilterTests. These are the changes that I made:

diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/server/DefaultSourceDirectoryUrlFilter.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/server/DefaultSourceDirectoryUrlFilter.java
index b2fb5a550d..0d16d82221 100644
--- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/server/DefaultSourceDirectoryUrlFilter.java
+++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/server/DefaultSourceDirectoryUrlFilter.java
@@ -17,9 +17,6 @@
 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;

@@ -40,9 +37,6 @@ public class DefaultSourceDirectoryUrlFilter implements SourceDirectoryUrlFilter

        private static final Pattern VERSION_PATTERN = Pattern.compile("^-\\d+(?:\\.\\d+)*(?:[.-].+)?$");

-       private static final Set<String> SKIPPED_PROJECTS = new HashSet<>(Arrays.asList("spring-boot",
-                       "spring-boot-devtools", "spring-boot-autoconfigure", "spring-boot-actuator", "spring-boot-starter"));
-
        @Override
        public boolean isMatch(String sourceDirectory, URL url) {
                String jarName = getJarName(url);
@@ -73,7 +67,7 @@ public class DefaultSourceDirectoryUrlFilter implements SourceDirectoryUrlFilter
        }

        private boolean isDirectoryMatch(String directory, String jarName) {
-               if (!jarName.startsWith(directory) || SKIPPED_PROJECTS.contains(directory)) {
+               if (!jarName.startsWith(directory)) {
                        return false;
                }
                String version = jarName.substring(directory.length());

Any ideas, @philwebb?

Comment From: philwebb

Sorry @wilkinsona, I've been looking at the commit logs and trying to remember but I have no idea.