diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java index 8c8491f3ff2ad..3fc9ece918749 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java @@ -1204,11 +1204,32 @@ private RuntimeUpdatesProcessor setWatchedFilePathsInternal(Map // Then process glob patterns for (Entry e : watchedFilePaths.entrySet()) { String watchedFilePath = e.getKey(); - Path path = Paths.get(watchedFilePath); - if (!path.isAbsolute() && !watchedRootPaths.contains(e.getKey()) && maybeGlobPattern(watchedFilePath)) { - Path resolvedPath = root.resolve(watchedFilePath); - for (WatchedPath extra : expandGlobPattern(root, resolvedPath, watchedFilePath, e.getValue())) { - timestamps.watchedPaths.put(extra.filePath, extra); + Path path = Paths.get(sanitizedPattern(watchedFilePath)); + if (!path.isAbsolute() && !watchedRootPaths.contains(e.getKey()) + && maybeGlobPattern(watchedFilePath)) { + try { + final PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + watchedFilePath); + Files.walkFileTree(root, new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { + Path relativePath = root.relativize(file); + if (matcher.matches(relativePath)) { + log.debugf("Glob pattern [%s] matched %s from %s", watchedFilePath, relativePath, + root); + WatchedPath extra = new WatchedPath(file, relativePath, e.getValue(), + attrs.lastModifiedTime().toMillis()); + timestamps.watchedPaths.put(extra.filePath, extra); + } + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFileFailed(Path file, IOException exc) { + return FileVisitResult.CONTINUE; + } + }); + } catch (IOException ex) { + throw new UncheckedIOException(ex); } } } @@ -1219,8 +1240,9 @@ private RuntimeUpdatesProcessor setWatchedFilePathsInternal(Map // Finally process watched absolute paths for (Entry e : watchedFilePaths.entrySet()) { String watchedFilePath = e.getKey(); - Path path = Paths.get(watchedFilePath); + Path path = Paths.get(sanitizedPattern(watchedFilePath)); if (path.isAbsolute()) { + path = Paths.get(watchedFilePath); log.debugf("Watch %s", path); if (Files.exists(path)) { putLastModifiedTime(path, path, e.getValue(), timestamps); @@ -1235,6 +1257,10 @@ private RuntimeUpdatesProcessor setWatchedFilePathsInternal(Map return this; } + private String sanitizedPattern(String pattern) { + return pattern.replaceAll("[*?]", ""); + } + private boolean maybeGlobPattern(String path) { return path.contains("*") || path.contains("?"); } @@ -1282,32 +1308,6 @@ public void close() throws IOException { } } - private List expandGlobPattern(Path root, Path path, String pattern, boolean restart) { - PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher("glob:" + path.toString()); - List files = new ArrayList<>(); - try { - Files.walkFileTree(root, new SimpleFileVisitor() { - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { - if (pathMatcher.matches(file)) { - Path relativePath = root.relativize(file); - log.debugf("Glob pattern [%s] matched %s from %s", pattern, relativePath, root); - files.add(new WatchedPath(file, relativePath, restart, attrs.lastModifiedTime().toMillis())); - } - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult visitFileFailed(Path file, IOException exc) { - return FileVisitResult.CONTINUE; - } - }); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - return files; - } - public boolean toggleInstrumentation() { instrumentationEnabled = !instrumentationEnabled(); if (instrumentationEnabled) { diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/welcome/WelcomeProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/welcome/WelcomeProcessor.java index 3638f28be7acf..201b09d741133 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/welcome/WelcomeProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/welcome/WelcomeProcessor.java @@ -72,11 +72,11 @@ private String getConfigFile(WorkspaceModule workspaceModule) { Path resourceDirs = resourcesDirs.iterator().next().getDir(); Path propertiesFile = resourceDirs.resolve("application.properties"); if (Files.exists(propertiesFile)) { - return propertiesFile.toString().substring((int) root.length() + 1); + return propertiesFile.toString().replace("\\", "/").substring((int) root.length() + 1); } Path propertiesYaml = resourceDirs.resolve("application.yaml"); if (Files.exists(propertiesYaml)) { - return propertiesYaml.toString().substring((int) root.length() + 1); + return propertiesYaml.toString().replace("\\", "/").substring((int) root.length() + 1); } } } @@ -91,7 +91,7 @@ private String getSourceDir(WorkspaceModule workspaceModule) { String root = moduleDir.toPath().toString(); Collection sourceDirs = workspaceModule.getMainSources().getSourceDirs(); if (sourceDirs != null && !sourceDirs.isEmpty()) { - String sourceDir = sourceDirs.iterator().next().getDir().toString(); + String sourceDir = sourceDirs.iterator().next().getDir().toString().replace("\\", "/"); return sourceDir.substring((int) root.length() + 1); } } @@ -106,7 +106,7 @@ private String getResourcesDir(WorkspaceModule workspaceModule) { String root = moduleDir.toPath().toString(); Collection resourcesDirs = workspaceModule.getMainSources().getResourceDirs(); if (resourcesDirs != null && !resourcesDirs.isEmpty()) { - String resourceDirs = resourcesDirs.iterator().next().getDir().toString(); + String resourceDirs = resourcesDirs.iterator().next().getDir().toString().replace("\\", "/"); return resourceDirs.substring((int) root.length() + 1); } } diff --git a/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/WebDependencyLocatorProcessor.java b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/WebDependencyLocatorProcessor.java index 15263d63e91ba..5954664dea853 100644 --- a/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/WebDependencyLocatorProcessor.java +++ b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/WebDependencyLocatorProcessor.java @@ -55,7 +55,7 @@ public void findRelevantFiles(BuildProducer feature, .resolve(config.webRoot); if (Files.exists(web)) { - hotDeploymentWatchedProducer.produce(new HotDeploymentWatchedFileBuildItem(config.webRoot + SLASH + STAR)); + hotDeploymentWatchedProducer.produce(new HotDeploymentWatchedFileBuildItem(config.webRoot + SLASH + STAR + STAR)); // Find all css and js (under /app) Path app = web .resolve(config.appRoot); @@ -65,7 +65,8 @@ public void findRelevantFiles(BuildProducer feature, if (Files.exists(app)) { hotDeploymentWatchedProducer - .produce(new HotDeploymentWatchedFileBuildItem(config.webRoot + SLASH + config.appRoot + SLASH + STAR)); + .produce(new HotDeploymentWatchedFileBuildItem( + config.webRoot + SLASH + config.appRoot + SLASH + STAR + STAR)); try (Stream appstream = Files.walk(app)) { appstream.forEach(path -> { if (Files.isRegularFile(path) && path.toString().endsWith(DOT_CSS)) { @@ -144,15 +145,16 @@ private static String processLine(String line, List cssFiles, List j try (StringWriter sw = new StringWriter()) { if (!cssFiles.isEmpty()) { for (Path css : cssFiles) { - sw.write(TAB2 + "" + NL); + sw.write(TAB2 + "" + + System.lineSeparator()); } } sw.write(TAB2 + IMPORTMAP_REPLACEMENT); if (!jsFiles.isEmpty()) { - sw.write(NL); - sw.write(TAB2 + ""); } @@ -321,6 +323,4 @@ static class LibInfo { private static final String DOT_HTML = ".html"; private static final String DOT_CSS = ".css"; private static final String DOT_JS = ".js"; - - private static final String NL = "\n"; }