File tree Expand file tree Collapse file tree 7 files changed +77
-0
lines changed
functionalTest/groovy/org/graalvm/buildtools/maven
main/java/org/graalvm/buildtools/maven
samples/java-application-with-tests Expand file tree Collapse file tree 7 files changed +77
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ This version introduces a breaking change: the plugin now requires Java 17 to ru
1212=== Maven plugin
1313
1414- Added support for running integration tests via maven-failsafe-plugin
15+ - Add `runtimeArgs` support to `native-maven-plugin`
1516
1617== Release 0.10.6
1718
Original file line number Diff line number Diff 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"]
Original file line number Diff line number Diff 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+ }
Original file line number Diff line number Diff line change 4141
4242package org.graalvm.buildtools.maven
4343
44+ import org.graalvm.buildtools.utils.NativeImageUtils
4445import spock.lang.IgnoreIf
4546import spock.lang.Issue
47+ import spock.lang.Requires
4648
4749class JavaApplicationWithTestsFunctionalTest extends AbstractGraalVMMavenFunctionalTest {
4850
@@ -182,4 +184,21 @@ class JavaApplicationWithTestsFunctionalTest extends AbstractGraalVMMavenFunctio
182184 outputDoesNotContain expectedOutput
183185 }
184186
187+ private static int getCurrentJDKVersion () {
188+ return NativeImageUtils . getMajorJDKVersion(GraalVMSupport . getGraalVMHomeVersionString())
189+ }
190+
191+ @Requires ({ getCurrentJDKVersion() >= 23 })
192+ def " can use the Maven plugin with the runtimeArgs config to run tests in a native image" () {
193+ withSample(" java-application-with-tests" )
194+
195+ when :
196+ mvn ' -Ptest-runtime-args' , ' -DquickBuild' , ' test'
197+
198+ def expectedOutput = " Note: this run will print partial stack traces of the locations where a"
199+
200+ then :
201+ buildSucceeded
202+ outputContains expectedOutput
203+ }
185204}
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -168,6 +168,9 @@ public void execute() throws MojoExecutionException {
168168 }
169169 systemProperties .put ("junit.platform.listeners.uid.tracking.output.dir" ,
170170 NativeExtension .testIdsDirectory (outputDirectory .getAbsolutePath ()));
171+ if (runtimeArgs == null ) {
172+ runtimeArgs = new ArrayList <>();
173+ }
171174
172175 imageName = NATIVE_TESTS_EXE ;
173176 mainClass = "org.graalvm.junit.platform.NativeImageJUnitLauncher" ;
@@ -238,6 +241,7 @@ private void runNativeTests(Path executable) throws MojoExecutionException {
238241 command .add ("--xml-output-dir" );
239242 command .add (xmlLocation .toString ());
240243 systemProperties .forEach ((key , value ) -> command .add ("-D" + key + "=" + value ));
244+ command .addAll (runtimeArgs );
241245
242246 processBuilder .command ().addAll (command );
243247 processBuilder .environment ().putAll (environment );
Original file line number Diff line number Diff line change 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 >--exact-reachability-metadata</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 >
You can’t perform that action at this time.
0 commit comments