Skip to content

Commit ddd0ebc

Browse files
authored
Merge pull request #47883 from zakkak/2025-05-15-implement-47762
Introduce property `quarkus.native.additional-build-args-append`
2 parents 0e57a60 + 54cbe3a commit ddd0ebc

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ public interface NativeConfig {
4242
*/
4343
Optional<List<String>> additionalBuildArgs();
4444

45+
/**
46+
* Comma-separated, additional arguments to pass to the build process.
47+
* The arguments are appended to those provided through {@link #additionalBuildArgs()}, as a result they may override those
48+
* passed through {@link #additionalBuildArgs()}.
49+
* By convention, this is meant to be set on the command-line, while {@link #additionalBuildArgs()} should be preferred for
50+
* use in properties files.
51+
* If an argument includes the {@code ,} symbol, it needs to be escaped, e.g. {@code \\,}
52+
*/
53+
Optional<List<String>> additionalBuildArgsAppend();
54+
4555
/**
4656
* If the HTTP url handler should be enabled, allowing you to do URL.openConnection() for HTTP URLs
4757
*/

core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,8 @@ public NativeImageInvokerInfo build() {
800800
* Instruct GraalVM / Mandrel to keep more accurate information about source locations when generating
801801
* debug info for debugging and monitoring tools. This parameter may break compatibility with Truffle.
802802
* Affected users should explicitly pass {@code -H:-TrackNodeSourcePosition} through
803-
* {@code quarkus.native.additional-build-args} to override it.
803+
* {@code quarkus.native.additional-build-args} or {@code quarkus.native.additional-build-args-append}
804+
* to override it.
804805
*
805806
* See https://github.com/quarkusio/quarkus/issues/30772 for more details.
806807
*/
@@ -849,8 +850,9 @@ public NativeImageInvokerInfo build() {
849850

850851
/*
851852
* Any parameters following this call are forced over the user provided parameters in
852-
* quarkus.native.additional-build-args. So if you need a parameter to be overridable through
853-
* quarkus.native.additional-build-args please make sure to add it before this call.
853+
* quarkus.native.additional-build-args or quarkus.native.additional-build-args-append. So if you need
854+
* a parameter to be overridable through quarkus.native.additional-build-args or
855+
* quarkus.native.additional-build-args-append please make sure to add it before this call.
854856
*/
855857
handleAdditionalProperties(nativeImageArgs);
856858

@@ -1061,8 +1063,13 @@ public NativeImageInvokerInfo build() {
10611063
}
10621064

10631065
private void handleAdditionalProperties(List<String> command) {
1064-
if (nativeConfig.additionalBuildArgs().isPresent()) {
1065-
List<String> strings = nativeConfig.additionalBuildArgs().get();
1066+
Optional<List<String>>[] additionalBuildArgs = new Optional[] { nativeConfig.additionalBuildArgs(),
1067+
nativeConfig.additionalBuildArgsAppend() };
1068+
for (Optional<List<String>> args : additionalBuildArgs) {
1069+
if (args.isEmpty()) {
1070+
continue;
1071+
}
1072+
List<String> strings = args.get();
10661073
for (String buildArg : strings) {
10671074
String trimmedBuildArg = buildArg.trim();
10681075
if (trimmedBuildArg.contains(TRUST_STORE_SYSTEM_PROPERTY_MARKER) && containerBuild) {

core/deployment/src/test/java/io/quarkus/deployment/pkg/TestNativeConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public Optional<List<String>> additionalBuildArgs() {
3535
return Optional.empty();
3636
}
3737

38+
@Override
39+
public Optional<List<String>> additionalBuildArgsAppend() {
40+
return Optional.empty();
41+
}
42+
3843
@Override
3944
public boolean enableHttpUrlHandler() {
4045
return false;

docs/src/main/asciidoc/building-native-image.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ If you have generated the application from the previous tutorial, you can find i
192192

193193
[TIP]
194194
====
195-
You can provide custom options for the `native-image` command using the `<quarkus.native.additional-build-args>` property.
195+
You can provide custom options for the `native-image` command using the `quarkus.native.additional-build-args` and `quarkus.native.additional-build-args-append` properties.
196196
Multiple options may be separated by a comma.
197197
198-
Another possibility is to include the `quarkus.native.additional-build-args` configuration property in your `application.properties`.
198+
By convention `quarkus.native.additional-build-args-append` is meant to be defined at the command line (e.g. `-Dquarkus.native.additional-build-args-append=--verbose`), while `quarkus.native.additional-build-args` may be defined either at the command line or in your `application.properties`. Note that, any arguments included in `quarkus.native.additional-build-args-append` may override those included in `quarkus.native.additional-build-args`.
199199
200200
You can find more information about how to configure the native image building process in the <<configuration-reference>> section below.
201201
====

0 commit comments

Comments
 (0)