diff --git a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java index 43cb4659a1634..67282afd1c3db 100644 --- a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java +++ b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java @@ -14,7 +14,6 @@ import java.io.UncheckedIOException; import java.lang.reflect.Modifier; import java.nio.charset.Charset; -import java.nio.file.FileSystem; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -2170,7 +2169,7 @@ private void scanPathTree(PathTree pathTree, TemplateRootsBuildItem templateRoot // if template root is found in this tree then walk over its subtree scanTemplateRootSubtree( new FilteredPathTree(pathTree, PathFilter.forIncludes(List.of(templateRoot + "/**"))), - visit.getPath(), watchedPaths, templatePaths, nativeImageResources, config); + visit.getRelativePath(), watchedPaths, templatePaths, nativeImageResources, config); } }); } @@ -3383,7 +3382,7 @@ private static void produceTemplateBuildItems(BuildProducer watchedPaths, BuildProducer templatePaths, BuildProducer nativeImageResources, @@ -3391,30 +3390,19 @@ private void scanTemplateRootSubtree(PathTree pathTree, Path templateRoot, pathTree.walk(visit -> { if (Files.isRegularFile(visit.getPath())) { LOGGER.debugf("Found template: %s", visit.getPath()); - String templatePath = toOsAgnosticPath(templateRoot.relativize(visit.getPath())); + // remove templateRoot + / + final String relativePath = visit.getRelativePath(); + String templatePath = relativePath.substring(templateRoot.length() + 1); if (config.templatePathExclude.matcher(templatePath).matches()) { LOGGER.debugf("Template file excluded: %s", visit.getPath()); return; } produceTemplateBuildItems(templatePaths, watchedPaths, nativeImageResources, - visit.getRelativePath("/"), - templatePath, visit.getPath(), config); + relativePath, templatePath, visit.getPath(), config); } }); } - private static String toOsAgnosticPath(String path, FileSystem fs) { - String separator = fs.getSeparator(); - if (!separator.equals("/")) { - path = path.replace(separator, "/"); - } - return path; - } - - private static String toOsAgnosticPath(Path path) { - return toOsAgnosticPath(path.toString(), path.getFileSystem()); - } - private static boolean isExcluded(TypeCheck check, Iterable> excludes) { for (Predicate exclude : excludes) { if (exclude.test(check)) { diff --git a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/paths/PathVisit.java b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/paths/PathVisit.java index 139560a3d40f1..5084405c4bdcf 100644 --- a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/paths/PathVisit.java +++ b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/paths/PathVisit.java @@ -44,6 +44,16 @@ default URL getUrl() { } } + /** + * Path relative to the root of the tree as a string with {@code /} as a path element separator. + * This method calls {@link #getRelativePath(String)} passing {@code /} as an argument. + * + * @return path relative to the root of the tree as a string with {@code /} as a path element separator + */ + default String getRelativePath() { + return getRelativePath("/"); + } + /** * Path relative to the root of the tree as a string with a provided path element separator. * For a {@link PathTree} created for an archive, the returned path will be relative to the root