Skip to content

Commit 7b02ea8

Browse files
committed
Deprecate quarkus.native.resources.excludes
The new `reachability-metadata.json` file doesn't allow the exclusion of resources and uses globs for the inclusion of them. See: * oracle/graal#7487 * oracle/graal#9048 * oracle/graal#12255
1 parent 95f89bc commit 7b02ea8

File tree

6 files changed

+70
-15
lines changed

6 files changed

+70
-15
lines changed

core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/NativeImageResourcePatternsBuildItem.java

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*/
3131
public final class NativeImageResourcePatternsBuildItem extends MultiBuildItem {
3232

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

3536
private final List<String> includePatterns;
@@ -39,6 +40,12 @@ private NativeImageResourcePatternsBuildItem(List<String> includePatterns, List<
3940
this.excludePatterns = excludePatterns;
4041
}
4142

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

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

@@ -72,7 +80,12 @@ public NativeImageResourcePatternsBuildItem build() {
7280
*
7381
* @param glob the glob pattern to add to the list of patterns to exclude
7482
* @return this {@link Builder}
83+
*
84+
* @deprecated Excluding resources is not supported in the new reachability-metadata.json file used with Mandrel/GraalVM
85+
* 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for Mandrel/GraalVM 23.1
86+
* for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
7587
*/
88+
@Deprecated(since = "3.29", forRemoval = true)
7689
public Builder excludeGlob(String glob) {
7790
excludePatterns.add(GlobUtil.toRegexPattern(glob));
7891
return this;
@@ -87,7 +100,12 @@ public Builder excludeGlob(String glob) {
87100
*
88101
* @param globs the glob patterns to add to the list of patterns to exclude
89102
* @return this {@link Builder}
103+
*
104+
* @deprecated Excluding resources is not supported in the new reachability-metadata.json file used with Mandrel/GraalVM
105+
* 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for Mandrel/GraalVM 23.1
106+
* for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
90107
*/
108+
@Deprecated(since = "3.29", forRemoval = true)
91109
public Builder excludeGlobs(Collection<String> globs) {
92110
globs.stream().map(GlobUtil::toRegexPattern).forEach(excludePatterns::add);
93111
return this;
@@ -102,7 +120,12 @@ public Builder excludeGlobs(Collection<String> globs) {
102120
*
103121
* @param globs the glob patterns to add to the list of patterns to exclude
104122
* @return this {@link Builder}
123+
*
124+
* @deprecated Excluding resources is not supported in the new reachability-metadata.json file used with Mandrel/GraalVM
125+
* 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for Mandrel/GraalVM 23.1
126+
* for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
105127
*/
128+
@Deprecated(since = "3.29", forRemoval = true)
106129
public Builder excludeGlobs(String... globs) {
107130
Stream.of(globs).map(GlobUtil::toRegexPattern).forEach(excludePatterns::add);
108131
return this;
@@ -116,7 +139,12 @@ public Builder excludeGlobs(String... globs) {
116139
*
117140
* @param pattern the regular expression to add to the list of patterns to exclude
118141
* @return this {@link Builder}
142+
*
143+
* @deprecated Excluding resources is not supported in the new reachability-metadata.json file used with Mandrel/GraalVM
144+
* 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for Mandrel/GraalVM 23.1
145+
* for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
119146
*/
147+
@Deprecated(since = "3.29", forRemoval = true)
120148
public Builder excludePattern(String pattern) {
121149
excludePatterns.add(pattern);
122150
return this;
@@ -130,7 +158,12 @@ public Builder excludePattern(String pattern) {
130158
*
131159
* @param patterns the regular expressions to add to the list of patterns to exclude
132160
* @return this {@link Builder}
161+
*
162+
* @deprecated Excluding resources is not supported in the new reachability-metadata.json file used with Mandrel/GraalVM
163+
* 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for Mandrel/GraalVM 23.1
164+
* for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
133165
*/
166+
@Deprecated(since = "3.29", forRemoval = true)
134167
public Builder excludePatterns(Collection<String> patterns) {
135168
excludePatterns.addAll(patterns);
136169
return this;
@@ -144,7 +177,12 @@ public Builder excludePatterns(Collection<String> patterns) {
144177
*
145178
* @param patterns the regular expressions to add to the list of patterns to exclude
146179
* @return this {@link Builder}
180+
*
181+
* @deprecated Excluding resources is not supported in the new reachability-metadata.json file used with Mandrel/GraalVM
182+
* 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for Mandrel/GraalVM 23.1
183+
* for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
147184
*/
185+
@Deprecated(since = "3.29", forRemoval = true)
148186
public Builder excludePatterns(String... patterns) {
149187
Stream.of(patterns).forEach(excludePatterns::add);
150188
return this;
@@ -187,8 +225,8 @@ public Builder includeGlobs(Collection<String> globs) {
187225
* @param globs the glob patterns to add
188226
* @return this {@link Builder}
189227
*/
190-
public Builder includeGlobs(String... patterns) {
191-
Stream.of(patterns).map(GlobUtil::toRegexPattern).forEach(includePatterns::add);
228+
public Builder includeGlobs(String... globs) {
229+
Stream.of(globs).map(GlobUtil::toRegexPattern).forEach(includePatterns::add);
192230
return this;
193231
}
194232

@@ -199,7 +237,12 @@ public Builder includeGlobs(String... patterns) {
199237
*
200238
* @param pattern the regular expression to add
201239
* @return this {@link Builder}
240+
*
241+
* @deprecated Including resources using patterns is not supported in the new reachability-metadata.json file used with
242+
* Mandrel/GraalVM 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for
243+
* Mandrel/GraalVM 23.1 for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
202244
*/
245+
@Deprecated(since = "3.29", forRemoval = true)
203246
public Builder includePattern(String pattern) {
204247
includePatterns.add(pattern);
205248
return this;
@@ -212,7 +255,12 @@ public Builder includePattern(String pattern) {
212255
*
213256
* @param patterns the regular expressions to add
214257
* @return this {@link Builder}
258+
*
259+
* @deprecated Including resources using patterns is not supported in the new reachability-metadata.json file used with
260+
* Mandrel/GraalVM 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for
261+
* Mandrel/GraalVM 23.1 for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
215262
*/
263+
@Deprecated(since = "3.29", forRemoval = true)
216264
public Builder includePatterns(Collection<String> patterns) {
217265
includePatterns.addAll(patterns);
218266
return this;
@@ -225,7 +273,12 @@ public Builder includePatterns(Collection<String> patterns) {
225273
*
226274
* @param patterns the regular expressions to add
227275
* @return this {@link Builder}
276+
*
277+
* @deprecated Including resources using patterns is not supported in the new reachability-metadata.json file used with
278+
* Mandrel/GraalVM 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for
279+
* Mandrel/GraalVM 23.1 for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
228280
*/
281+
@Deprecated(since = "3.29", forRemoval = true)
229282
public Builder includePatterns(String... patterns) {
230283
Stream.of(patterns).forEach(includePatterns::add);
231284
return this;

core/deployment/src/main/java/io/quarkus/deployment/pkg/NativeConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,12 @@ interface ResourcesConfig {
488488
* <p>
489489
* the resource {@code red.png} will be available in the native image while the resources {@code foo/green.png}
490490
* and {@code bar/blue.png} will not be available in the native image.
491+
*
492+
* @deprecated Excluding resources is not supported in the new reachability-metadata.json file used with Mandrel/GraalVM
493+
* 25.0 and onwards. Quarkus plans to adopt the use of reachability-metadata.json for Mandrel/GraalVM 23.1
494+
* for JDK 21 as well (see https://github.com/quarkusio/quarkus/issues/41016)
491495
*/
496+
@Deprecated(since = "3.29", forRemoval = true)
492497
Optional<List<String>> excludes();
493498
}
494499

docs/src/main/asciidoc/writing-native-applications-tips.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,19 @@ Other resources should be declared explicitly.
3939

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

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

45-
Both configuration properties support glob patterns.
46-
47-
For instance, having the following properties in your `application.properties`:
45+
For instance, having the following property in your `application.properties`:
4846

4947
[source,properties]
5048
----
5149
quarkus.native.resources.includes=foo/**,bar/**/*.txt
52-
quarkus.native.resources.excludes=foo/private/**
5350
----
5451

5552
will include:
5653

57-
* all files in the `foo/` directory and its subdirectories except for files in `foo/private/` and its subdirectories,
54+
* all files in the `foo/` directory and its subdirectories,
5855
* all text files in the `bar/` directory and its subdirectories.
5956

6057
==== Using a configuration file

extensions/awt/deployment/src/main/java/io/quarkus/awt/deployment/AwtProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ void resources(
8080
BuildProducer<NativeImageResourcePatternsBuildItem> resourcePatternsBuildItemBuildProducer) {
8181
resourcePatternsBuildItemBuildProducer
8282
.produce(NativeImageResourcePatternsBuildItem.builder()
83-
.includePattern(".*/iio-plugin.*properties$") // Texts for e.g. exceptions strings
84-
.includePattern(".*/.*pf$") // Default colour profiles
83+
.includeGlobs("**/iio-plugin*.properties", // Texts for e.g. exceptions strings
84+
"**/*.pf") // Default colour profiles
8585
.build());
8686
}
8787

extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,6 @@ private static XmlAccessType getXmlAccessType(ClassInfo classInfo) {
548548
@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
549549
void jaxbIndex(final BuildProducer<NativeImageResourcePatternsBuildItem> resource) {
550550
LOG.debug("adding jaxb.index to native image resources");
551-
resource.produce(NativeImageResourcePatternsBuildItem.builder().includePattern(".*/jaxb.index$").build());
551+
resource.produce(NativeImageResourcePatternsBuildItem.builder().includeGlob("**/jaxb.index").build());
552552
}
553553
}

extensions/kotlin/deployment/src/main/java/io/quarkus/kotlin/deployment/KotlinProcessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ void registerKotlinReflection(final BuildProducer<ReflectiveClassBuildItem> refl
7272
.builder("kotlin.collections.EmptyList", "kotlin.collections.EmptyMap", "kotlin.collections.EmptySet")
7373
.build());
7474

75-
nativeResourcePatterns.produce(builder().includePatterns(
76-
"META-INF/.*.kotlin_module$",
75+
nativeResourcePatterns.produce(builder().includeGlobs(
76+
"META-INF/**/*.kotlin_module",
7777
"META-INF/services/kotlin.reflect.*",
78-
".*.kotlin_builtins")
78+
"*.kotlin_builtins")
7979
.build());
8080

8181
reflectiveHierarchyIgnoreWarning.produce(

0 commit comments

Comments
 (0)