From 2585bb0c5a8e8e4e758d4d6e49d98b13380267f6 Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Mon, 22 Apr 2024 14:18:37 +0300 Subject: [PATCH 1/2] Fix resource registration for native compilation NativeImageResourceBuildItem and ServiceProviderBuildItem contain a path of the resource we should include and not a pattern or a glob. As a result, `Pattern.quote` is the right method to use in order to produce a pattern that would match the path. The patch also remove the wrong addition of the paths "as is" to the includes json array. Fix up of b7f49dd9d952a46fde3f0abaabcc08b1a2e5f067 --- .../deployment/steps/NativeImageResourceConfigStep.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageResourceConfigStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageResourceConfigStep.java index 84a002343b29e..936eb56a03614 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageResourceConfigStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageResourceConfigStep.java @@ -4,6 +4,7 @@ import java.io.StringWriter; import java.nio.charset.StandardCharsets; import java.util.List; +import java.util.regex.Pattern; import io.quarkus.builder.Json; import io.quarkus.builder.Json.JsonArrayBuilder; @@ -16,7 +17,6 @@ import io.quarkus.deployment.builditem.nativeimage.NativeImageResourcePatternsBuildItem; import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; -import io.quarkus.util.GlobUtil; public class NativeImageResourceConfigStep { @@ -35,14 +35,13 @@ void generateResourceConfig(BuildProducer resourceCo for (NativeImageResourceBuildItem i : resources) { for (String path : i.getResources()) { JsonObjectBuilder pat = Json.object(); - pat.put("pattern", GlobUtil.toRegexPattern(path)); + pat.put("pattern", Pattern.quote(path)); includes.add(pat); } - addListToJsonArray(includes, i.getResources()); } for (ServiceProviderBuildItem i : serviceProviderBuildItems) { - includes.add(Json.object().put("pattern", GlobUtil.toRegexPattern(i.serviceDescriptorFile()))); + includes.add(Json.object().put("pattern", Pattern.quote(i.serviceDescriptorFile()))); } for (NativeImageResourcePatternsBuildItem resourcePatternsItem : resourcePatterns) { From 757537b21b8c859c075349abd706642e0e315982 Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Mon, 22 Apr 2024 15:06:49 +0300 Subject: [PATCH 2/2] Add documentation to NativeImageResourceBuildItem's constructors --- .../builditem/nativeimage/NativeImageResourceBuildItem.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/NativeImageResourceBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/NativeImageResourceBuildItem.java index 56ecff462a4d0..f58313c940ae5 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/NativeImageResourceBuildItem.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/NativeImageResourceBuildItem.java @@ -7,7 +7,11 @@ import io.quarkus.builder.item.MultiBuildItem; /** - * A build item that indicates that a static resource should be included in the native image + * A build item that indicates that a static resource should be included in the native image. + *

+ * A static resource is a file that is not processed by the build steps, but is included in the native image as-is. + * The resource path passed to the constructor is a {@code /}-separated path name (with the same semantics as the parameters + * passed to {@link java.lang.ClassLoader#getResources(String)}. *

* Related build items: *