Skip to content

Commit

Permalink
Qute: use the relative resource path for NativeImageResourceBuildItem
Browse files Browse the repository at this point in the history
- previously, we used incorrectly an OS-specific relative path

(cherry picked from commit 202ea6e)
  • Loading branch information
mkouba authored and gsmet committed Apr 23, 2024
1 parent 559f617 commit 44026ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<TemplatePathBuildItem> templatePaths,
BuildProducer<HotDeploymentWatchedFileBuildItem> watchedPaths,
BuildProducer<NativeImageResourceBuildItem> nativeImageResources, String osSpecificResourcePath,
BuildProducer<NativeImageResourceBuildItem> 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)));
Expand All @@ -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);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ public void execute(BuildContext context) {
List<NativeImageResourceBuildItem> 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++;
}
}
Expand Down

0 comments on commit 44026ec

Please sign in to comment.