Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*/
public final class NativeImageResourcePatternsBuildItem extends MultiBuildItem {

@Deprecated(since = "3.29", forRemoval = true)
private final List<String> excludePatterns;

private final List<String> includePatterns;
Expand All @@ -39,6 +40,12 @@ private NativeImageResourcePatternsBuildItem(List<String> includePatterns, List<
this.excludePatterns = excludePatterns;
}

/**
* @deprecated Excluding resources is not supported in the new reachability-metadata.json file used with Mandrel/GraalVM
* 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for Mandrel/GraalVM 23.1 for
* JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
*/
@Deprecated(since = "3.29", forRemoval = true)
public List<String> getExcludePatterns() {
return excludePatterns;
}
Expand All @@ -52,6 +59,7 @@ public static Builder builder() {
}

public static class Builder {
@Deprecated(since = "3.29", forRemoval = true)
private List<String> excludePatterns = new ArrayList<>();
private List<String> includePatterns = new ArrayList<>();

Expand All @@ -72,7 +80,12 @@ public NativeImageResourcePatternsBuildItem build() {
*
* @param glob the glob pattern to add to the list of patterns to exclude
* @return this {@link Builder}
*
* @deprecated Excluding resources is not supported in the new reachability-metadata.json file used with Mandrel/GraalVM
* 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for Mandrel/GraalVM 23.1
* for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
*/
@Deprecated(since = "3.29", forRemoval = true)
public Builder excludeGlob(String glob) {
excludePatterns.add(GlobUtil.toRegexPattern(glob));
return this;
Expand All @@ -87,7 +100,12 @@ public Builder excludeGlob(String glob) {
*
* @param globs the glob patterns to add to the list of patterns to exclude
* @return this {@link Builder}
*
* @deprecated Excluding resources is not supported in the new reachability-metadata.json file used with Mandrel/GraalVM
* 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for Mandrel/GraalVM 23.1
* for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
*/
@Deprecated(since = "3.29", forRemoval = true)
public Builder excludeGlobs(Collection<String> globs) {
globs.stream().map(GlobUtil::toRegexPattern).forEach(excludePatterns::add);
return this;
Expand All @@ -102,7 +120,12 @@ public Builder excludeGlobs(Collection<String> globs) {
*
* @param globs the glob patterns to add to the list of patterns to exclude
* @return this {@link Builder}
*
* @deprecated Excluding resources is not supported in the new reachability-metadata.json file used with Mandrel/GraalVM
* 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for Mandrel/GraalVM 23.1
* for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
*/
@Deprecated(since = "3.29", forRemoval = true)
public Builder excludeGlobs(String... globs) {
Stream.of(globs).map(GlobUtil::toRegexPattern).forEach(excludePatterns::add);
return this;
Expand All @@ -116,7 +139,12 @@ public Builder excludeGlobs(String... globs) {
*
* @param pattern the regular expression to add to the list of patterns to exclude
* @return this {@link Builder}
*
* @deprecated Excluding resources is not supported in the new reachability-metadata.json file used with Mandrel/GraalVM
* 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for Mandrel/GraalVM 23.1
* for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
*/
@Deprecated(since = "3.29", forRemoval = true)
public Builder excludePattern(String pattern) {
excludePatterns.add(pattern);
return this;
Expand All @@ -130,7 +158,12 @@ public Builder excludePattern(String pattern) {
*
* @param patterns the regular expressions to add to the list of patterns to exclude
* @return this {@link Builder}
*
* @deprecated Excluding resources is not supported in the new reachability-metadata.json file used with Mandrel/GraalVM
* 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for Mandrel/GraalVM 23.1
* for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
*/
@Deprecated(since = "3.29", forRemoval = true)
public Builder excludePatterns(Collection<String> patterns) {
excludePatterns.addAll(patterns);
return this;
Expand All @@ -144,7 +177,12 @@ public Builder excludePatterns(Collection<String> patterns) {
*
* @param patterns the regular expressions to add to the list of patterns to exclude
* @return this {@link Builder}
*
* @deprecated Excluding resources is not supported in the new reachability-metadata.json file used with Mandrel/GraalVM
* 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for Mandrel/GraalVM 23.1
* for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
*/
@Deprecated(since = "3.29", forRemoval = true)
public Builder excludePatterns(String... patterns) {
Stream.of(patterns).forEach(excludePatterns::add);
return this;
Expand Down Expand Up @@ -187,8 +225,8 @@ public Builder includeGlobs(Collection<String> globs) {
* @param globs the glob patterns to add
* @return this {@link Builder}
*/
public Builder includeGlobs(String... patterns) {
Stream.of(patterns).map(GlobUtil::toRegexPattern).forEach(includePatterns::add);
public Builder includeGlobs(String... globs) {
Stream.of(globs).map(GlobUtil::toRegexPattern).forEach(includePatterns::add);
return this;
}

Expand All @@ -199,7 +237,12 @@ public Builder includeGlobs(String... patterns) {
*
* @param pattern the regular expression to add
* @return this {@link Builder}
*
* @deprecated Including resources using patterns is not supported in the new reachability-metadata.json file used with
* Mandrel/GraalVM 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for
* Mandrel/GraalVM 23.1 for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
*/
@Deprecated(since = "3.29", forRemoval = true)
public Builder includePattern(String pattern) {
includePatterns.add(pattern);
return this;
Expand All @@ -212,7 +255,12 @@ public Builder includePattern(String pattern) {
*
* @param patterns the regular expressions to add
* @return this {@link Builder}
*
* @deprecated Including resources using patterns is not supported in the new reachability-metadata.json file used with
* Mandrel/GraalVM 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for
* Mandrel/GraalVM 23.1 for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
*/
@Deprecated(since = "3.29", forRemoval = true)
public Builder includePatterns(Collection<String> patterns) {
includePatterns.addAll(patterns);
return this;
Expand All @@ -225,7 +273,12 @@ public Builder includePatterns(Collection<String> patterns) {
*
* @param patterns the regular expressions to add
* @return this {@link Builder}
*
* @deprecated Including resources using patterns is not supported in the new reachability-metadata.json file used with
* Mandrel/GraalVM 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for
* Mandrel/GraalVM 23.1 for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
*/
@Deprecated(since = "3.29", forRemoval = true)
public Builder includePatterns(String... patterns) {
Stream.of(patterns).forEach(includePatterns::add);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,12 @@ interface ResourcesConfig {
* <p>
* the resource {@code red.png} will be available in the native image while the resources {@code foo/green.png}
* and {@code bar/blue.png} will not be available in the native image.
*
* @deprecated Excluding resources is not supported in the new reachability-metadata.json file used with Mandrel/GraalVM
* 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for Mandrel/GraalVM 23.1
* for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
*/
@Deprecated(since = "3.29", forRemoval = true)
Optional<List<String>> excludes();
}

Expand Down
11 changes: 4 additions & 7 deletions docs/src/main/asciidoc/writing-native-applications-tips.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,19 @@ Other resources should be declared explicitly.

==== Using the `quarkus.native.resources.includes` configuration property

To include more resources in the native executable, the easiest way is to use the `quarkus.native.resources.includes` configuration property,
and its counterpart to exclude resources `quarkus.native.resources.excludes`.
To include more resources in the native executable, the easiest way is to use the `quarkus.native.resources.includes` configuration property.
The configuration property supports glob patterns.

Both configuration properties support glob patterns.

For instance, having the following properties in your `application.properties`:
For instance, having the following property in your `application.properties`:

[source,properties]
----
quarkus.native.resources.includes=foo/**,bar/**/*.txt
quarkus.native.resources.excludes=foo/private/**
----

will include:

* all files in the `foo/` directory and its subdirectories except for files in `foo/private/` and its subdirectories,
* all files in the `foo/` directory and its subdirectories,
* all text files in the `bar/` directory and its subdirectories.

==== Using a configuration file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ void resources(
BuildProducer<NativeImageResourcePatternsBuildItem> resourcePatternsBuildItemBuildProducer) {
resourcePatternsBuildItemBuildProducer
.produce(NativeImageResourcePatternsBuildItem.builder()
.includePattern(".*/iio-plugin.*properties$") // Texts for e.g. exceptions strings
.includePattern(".*/.*pf$") // Default colour profiles
.includeGlobs("**/iio-plugin*.properties", // Texts for e.g. exceptions strings
"**/*.pf") // Default colour profiles
Comment on lines -83 to +84
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Karm please confirm that the new globs capture what you intended to capture with the patterns. Thanks

.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,6 @@ private static XmlAccessType getXmlAccessType(ClassInfo classInfo) {
@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
void jaxbIndex(final BuildProducer<NativeImageResourcePatternsBuildItem> resource) {
LOG.debug("adding jaxb.index to native image resources");
resource.produce(NativeImageResourcePatternsBuildItem.builder().includePattern(".*/jaxb.index$").build());
resource.produce(NativeImageResourcePatternsBuildItem.builder().includeGlob("**/jaxb.index").build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ void registerKotlinReflection(final BuildProducer<ReflectiveClassBuildItem> refl
.builder("kotlin.collections.EmptyList", "kotlin.collections.EmptyMap", "kotlin.collections.EmptySet")
.build());

nativeResourcePatterns.produce(builder().includePatterns(
"META-INF/.*.kotlin_module$",
nativeResourcePatterns.produce(builder().includeGlobs(
"META-INF/**/*.kotlin_module",
"META-INF/services/kotlin.reflect.*",
".*.kotlin_builtins")
"**/*.kotlin_builtins")
Comment on lines -75 to +78
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@geoand please confirm that the new globs capture what you intended to capture with the patterns. Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember for sure, but I'm pretty sure the pattern wasn't meant to capture the files in an arbitrary depth

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I know for sure that *.kotlin_builtins didn't work, so it was meant to capture at least "some" depth. Furthermore, even if not meant to do so .* does capture arbitrary depth. What do you suggest?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this works and attempts did it, let's go ahead with it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the new patterns do what the old ones did so they are good enough IMHO.

.build());

reflectiveHierarchyIgnoreWarning.produce(
Expand Down
Loading