Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/src/docs/asciidoc/changelog.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This version introduces a breaking change: the plugin now requires Java 17 to ru
=== Maven plugin
Copy link
Member

Choose a reason for hiding this comment

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

@dnestoro will this go into 0.11.0? If not, please adjust it


- Added support for running integration tests via maven-failsafe-plugin
- Add `runtimeArgs` support to `native-maven-plugin`

== Release 0.10.6

Expand Down
11 changes: 11 additions & 0 deletions docs/src/docs/asciidoc/maven-plugin.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ The following configuration options are available:
<propertyName>value</propertyName>
</systemPropertyVariables>
----
`<runtimeArgs>`::
To specify runtime arguments used for a native image run, use:
[source,xml, role="multi-language-sample"]
----
<runtimeArgs>
<runtimeArg>-XX:MissingRegistrationReportingMode=Warn</runtimeArg>
</runtimeArgs>
----

This parameter is only valid for the Maven Goal of `test`.

`<jvmArgs>`::
To specify JVM arguments used for a native image build, use:
[source,xml, role="multi-language-sample"]
Expand Down
4 changes: 4 additions & 0 deletions native-maven-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,7 @@ tasks.withType<Checkstyle>().configureEach {
// generated code
exclude("**/RuntimeMetadata*")
}

tasks {
withType<Javadoc>().configureEach { options.encoding = "UTF-8" }
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@

package org.graalvm.buildtools.maven

import org.graalvm.buildtools.utils.NativeImageUtils
import spock.lang.IgnoreIf
import spock.lang.Issue
import spock.lang.Requires

class JavaApplicationWithTestsFunctionalTest extends AbstractGraalVMMavenFunctionalTest {

Expand Down Expand Up @@ -182,4 +184,21 @@ class JavaApplicationWithTestsFunctionalTest extends AbstractGraalVMMavenFunctio
outputDoesNotContain expectedOutput
}

private static int getCurrentJDKVersion() {
return NativeImageUtils.getMajorJDKVersion(GraalVMSupport.getGraalVMHomeVersionString())
}

@Requires({ getCurrentJDKVersion() >= 23 })
def "can use the Maven plugin with the runtimeArgs config to run tests in a native image"() {
withSample("java-application-with-tests")

when:
mvn '-Ptest-runtime-args', '-DquickBuild', 'test'

def expectedOutput = "Note: this run will print partial stack traces of the locations where a"

then:
buildSucceeded
outputContains expectedOutput
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ public abstract class AbstractNativeImageMojo extends AbstractNativeMojo {
@Parameter(property = "jvmArgs")
protected List<String> jvmArgs;

@Parameter(property = "runtimeArgs")
protected List<String> runtimeArgs;

@Parameter(property = NATIVE_IMAGE_DRY_RUN, defaultValue = "false")
protected boolean dryRun;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ public void execute() throws MojoExecutionException {
}
systemProperties.put("junit.platform.listeners.uid.tracking.output.dir",
NativeExtension.testIdsDirectory(outputDirectory.getAbsolutePath()));
if (runtimeArgs == null) {
runtimeArgs = new ArrayList<>();
}

imageName = NATIVE_TESTS_EXE;
mainClass = "org.graalvm.junit.platform.NativeImageJUnitLauncher";
Expand Down Expand Up @@ -238,6 +241,7 @@ private void runNativeTests(Path executable) throws MojoExecutionException {
command.add("--xml-output-dir");
command.add(xmlLocation.toString());
systemProperties.forEach((key, value) -> command.add("-D" + key + "=" + value));
command.addAll(runtimeArgs);

processBuilder.command().addAll(command);
processBuilder.environment().putAll(environment);
Expand Down
35 changes: 35 additions & 0 deletions samples/java-application-with-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,41 @@
</plugins>
</build>
</profile>
<profile>
<id>test-runtime-args</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${native.maven.plugin.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<id>test-native</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
<configuration>
<buildArgs>
<buildArg>--exact-reachability-metadata</buildArg>
</buildArgs>
<runtimeArgs>
<runtimeArg>-XX:MissingRegistrationReportingMode=Warn</runtimeArg>
</runtimeArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
Expand Down
Loading