Skip to content

Commit 581d0c1

Browse files
committed
Add runtimeArgs support to native-maven-plugin
1 parent a4fbd52 commit 581d0c1

File tree

6 files changed

+71
-0
lines changed

6 files changed

+71
-0
lines changed

docs/src/docs/asciidoc/changelog.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
This version introduces a breaking change: the plugin now requires Java 17 to run.
77

8+
=== Maven plugin
9+
10+
- Add `runtimeArgs` support to `native-maven-plugin`
11+
812
== Release 0.10.6
913

1014
=== Gradle plugin

docs/src/docs/asciidoc/maven-plugin.adoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ The following configuration options are available:
119119
<propertyName>value</propertyName>
120120
</systemPropertyVariables>
121121
----
122+
`<runtimeArgs>`::
123+
To specify runtime arguments used for a native image run, use:
124+
[source,xml, role="multi-language-sample"]
125+
----
126+
<runtimeArgs>
127+
<runtimeArg>-XX:MissingRegistrationReportingMode=Warn</runtimeArg>
128+
</runtimeArgs>
129+
----
130+
131+
This parameter is only valid for the Maven Goal of `test`.
132+
122133
`<jvmArgs>`::
123134
To specify JVM arguments used for a native image build, use:
124135
[source,xml, role="multi-language-sample"]

native-maven-plugin/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,7 @@ tasks.withType<Checkstyle>().configureEach {
178178
// generated code
179179
exclude("**/RuntimeMetadata*")
180180
}
181+
182+
tasks {
183+
withType<Javadoc>().configureEach { options.encoding = "UTF-8" }
184+
}

native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/AbstractNativeImageMojo.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ public abstract class AbstractNativeImageMojo extends AbstractNativeMojo {
168168
@Parameter(property = "jvmArgs")
169169
protected List<String> jvmArgs;
170170

171+
@Parameter(property = "runtimeArgs")
172+
protected List<String> runtimeArgs;
173+
171174
@Parameter(property = NATIVE_IMAGE_DRY_RUN, defaultValue = "false")
172175
protected boolean dryRun;
173176

native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/NativeTestMojo.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ public void execute() throws MojoExecutionException {
169169
}
170170
systemProperties.put("junit.platform.listeners.uid.tracking.output.dir",
171171
NativeExtension.testIdsDirectory(outputDirectory.getAbsolutePath()));
172+
if (runtimeArgs == null) {
173+
runtimeArgs = new ArrayList<>();
174+
}
172175

173176
imageName = NATIVE_TESTS_EXE;
174177
mainClass = "org.graalvm.junit.platform.NativeImageJUnitLauncher";
@@ -204,6 +207,16 @@ private void configureEnvironment() {
204207
systemProperties.put(child.getName(), child.getValue());
205208
}
206209
}
210+
Xpp3Dom runtimeArguments = dom.getChild("runtimeArgs");
211+
if (runtimeArguments != null) {
212+
Xpp3Dom[] children = runtimeArguments.getChildren();
213+
if (runtimeArgs == null) {
214+
runtimeArgs = new ArrayList<>(children.length);
215+
}
216+
for (Xpp3Dom child : children) {
217+
runtimeArgs.add(child.getValue());
218+
}
219+
}
207220
}
208221
}
209222
}
@@ -235,6 +248,7 @@ private void runNativeTests(Path executable) throws MojoExecutionException {
235248
command.add("--xml-output-dir");
236249
command.add(xmlLocation.toString());
237250
systemProperties.forEach((key, value) -> command.add("-D" + key + "=" + value));
251+
command.addAll(runtimeArgs);
238252

239253
processBuilder.command().addAll(command);
240254
processBuilder.environment().putAll(environment);

samples/java-application-with-tests/pom.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,41 @@
238238
</plugins>
239239
</build>
240240
</profile>
241+
<profile>
242+
<id>test-runtime-args</id>
243+
<build>
244+
<plugins>
245+
<plugin>
246+
<groupId>org.apache.maven.plugins</groupId>
247+
<artifactId>maven-surefire-plugin</artifactId>
248+
<version>3.0.0-M5</version>
249+
</plugin>
250+
<plugin>
251+
<groupId>org.graalvm.buildtools</groupId>
252+
<artifactId>native-maven-plugin</artifactId>
253+
<version>${native.maven.plugin.version}</version>
254+
<extensions>true</extensions>
255+
<executions>
256+
<execution>
257+
<id>test-native</id>
258+
<goals>
259+
<goal>test</goal>
260+
</goals>
261+
<phase>test</phase>
262+
</execution>
263+
</executions>
264+
<configuration>
265+
<buildArgs>
266+
<buildArg>-H:ThrowMissingRegistrationErrors=</buildArg>
267+
</buildArgs>
268+
<runtimeArgs>
269+
<runtimeArg>-XX:MissingRegistrationReportingMode=Warn</runtimeArg>
270+
</runtimeArgs>
271+
</configuration>
272+
</plugin>
273+
</plugins>
274+
</build>
275+
</profile>
241276
</profiles>
242277

243278
<build>

0 commit comments

Comments
 (0)