Skip to content

Commit

Permalink
Fix resource registration for native compilation
Browse files Browse the repository at this point in the history
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 b7f49dd

(cherry picked from commit 2585bb0)
  • Loading branch information
zakkak authored and gsmet committed Apr 23, 2024
1 parent cfe59bb commit d02685b
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand All @@ -35,14 +35,13 @@ void generateResourceConfig(BuildProducer<GeneratedResourceBuildItem> 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) {
Expand Down

0 comments on commit d02685b

Please sign in to comment.