From 44026ec3a44b290418926d79ac768bf22f3cde7c Mon Sep 17 00:00:00 2001 From: Martin Kouba Date: Fri, 19 Apr 2024 15:39:25 +0200 Subject: [PATCH] Qute: use the relative resource path for NativeImageResourceBuildItem - previously, we used incorrectly an OS-specific relative path (cherry picked from commit 202ea6e107da27118052ad2feb9de95690525f7f) --- .../quarkus/qute/deployment/QuteProcessor.java | 16 +++++++--------- .../templateroot/AdditionalTemplateRootTest.java | 5 +---- 2 files changed, 8 insertions(+), 13 deletions(-) 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 9437d09d5872a..f7430ed6b1733 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 @@ -3355,31 +3355,29 @@ public static String getName(InjectionPointInfo injectionPoint) { * @param templatePaths * @param watchedPaths * @param nativeImageResources - * @param osSpecificResourcePath The OS-specific resource path, i.e. templates\nested\foo.html + * @param resourcePath The relative resource path, including the template root * @param templatePath The path relative to the template root; using the {@code /} path separator * @param originalPath * @param config */ private static void produceTemplateBuildItems(BuildProducer templatePaths, BuildProducer watchedPaths, - BuildProducer nativeImageResources, String osSpecificResourcePath, + BuildProducer nativeImageResources, String resourcePath, String templatePath, Path originalPath, QuteConfig config) { if (templatePath.isEmpty()) { return; } - // OS-agnostic full path, i.e. templates/foo.html - String osAgnosticResourcePath = toOsAgnosticPath(osSpecificResourcePath, originalPath.getFileSystem()); LOGGER.debugf("Produce template build items [templatePath: %s, osSpecificResourcePath: %s, originalPath: %s", templatePath, - osSpecificResourcePath, + resourcePath, originalPath); boolean restartNeeded = true; if (config.devMode.noRestartTemplates.isPresent()) { - restartNeeded = !config.devMode.noRestartTemplates.get().matcher(osAgnosticResourcePath).matches(); + restartNeeded = !config.devMode.noRestartTemplates.get().matcher(resourcePath).matches(); } - watchedPaths.produce(new HotDeploymentWatchedFileBuildItem(osAgnosticResourcePath, restartNeeded)); - nativeImageResources.produce(new NativeImageResourceBuildItem(osSpecificResourcePath)); + watchedPaths.produce(new HotDeploymentWatchedFileBuildItem(resourcePath, restartNeeded)); + nativeImageResources.produce(new NativeImageResourceBuildItem(resourcePath)); templatePaths.produce( new TemplatePathBuildItem(templatePath, originalPath, readTemplateContent(originalPath, config.defaultCharset))); @@ -3399,7 +3397,7 @@ private void scanTemplateRootSubtree(PathTree pathTree, Path templateRoot, return; } produceTemplateBuildItems(templatePaths, watchedPaths, nativeImageResources, - visit.getRelativePath(visit.getPath().getFileSystem().getSeparator()), + visit.getRelativePath("/"), templatePath, visit.getPath(), config); } }); diff --git a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/templateroot/AdditionalTemplateRootTest.java b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/templateroot/AdditionalTemplateRootTest.java index 9095a01599387..37b3606d7a096 100644 --- a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/templateroot/AdditionalTemplateRootTest.java +++ b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/templateroot/AdditionalTemplateRootTest.java @@ -51,11 +51,8 @@ public void execute(BuildContext context) { List items = context.consumeMulti(NativeImageResourceBuildItem.class); for (NativeImageResourceBuildItem item : items) { if (item.getResources().contains("web/public/hello.txt") - || item.getResources().contains("web\\public\\hello.txt") || item.getResources().contains("templates/hi.txt") - || item.getResources().contains("templates\\hi.txt") - || item.getResources().contains("templates/nested/hoho.txt") - || item.getResources().contains("templates\\nested\\hoho.txt")) { + || item.getResources().contains("templates/nested/hoho.txt")) { found++; } }