Skip to content

Commit

Permalink
Merge pull request #40184 from zakkak/2024-04-22-fix-double-resource-…
Browse files Browse the repository at this point in the history
…registration

Fix resource registration for native compilation
  • Loading branch information
mkouba authored Apr 23, 2024
2 parents 70af955 + 757537b commit 94fceeb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* 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)}.
* <p>
* Related build items:
* <ul>
Expand Down
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 94fceeb

Please sign in to comment.