Skip to content

Maven GraalVm native tests (mvn -PnativeTest test) #33624

@trcoelho

Description

@trcoelho

Hello!

Just generated a new maven spring boot project on Spring Initializr (https://start.spring.io/) using version 3.0.0, Java 17 and GraalVM Native Support.

Application build natively successfully, however it does not when you run native tests as per informed on Spring Boot Reference Documentation (https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#native-image.testing.with-native-build-tools.maven) as follows:

Command:
mvn -PnativeTest test

Log:

[INFO]
[INFO] --- native-maven-plugin:0.9.18:test (native-test) @ demo ---
[INFO] ====================
[INFO] Initializing project: demo
[INFO] ====================
[INFO] Found GraalVM installation from JAVA_HOME variable.
[INFO] Downloaded GraalVM reachability metadata repository from file:/C:/Users/ricsfd/.m2/repository/org/graalvm/buildtools/graalvm-reachability-metadata/0.9.18/graalvm-reachability-metadata-0.9.18-repository.zip
[INFO] [graalvm reachability metadata repository for ch.qos.logback:logback-classic:1.4.5]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for ch.qos.logback:logback-classic:1.4.5]: Configuration directory is ch.qos.logback\logback-classic\1.4.1
[INFO] Executing: C:\Program Files\BellSoft\LibericaNIK-Full-22-OpenJDK-17\bin\native-image.cmd @target\tmp\native-image-5826493397404161278.args
========================================================================================================================
GraalVM Native Image: Generating 'native-tests.exe' (executable)...
========================================================================================================================

[1/7] Initializing...                                                                                    (0.0s @ 0.30GB)
Error: Default native-compiler executable 'cl.exe' not found via environment variable PATH
Error: To prevent native-toolchain checking provide command-line option -H:-CheckToolchain
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
------------------------------------------------------------------------------------------------------------------------
                         0.3s (3.2% of total time) in 8 GCs | Peak RSS: 0.65GB | CPU load: 0.47
========================================================================================================================
Failed generating 'native-tests.exe' after 8.3s.
Error: Image build request failed with exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  23.657 s
[INFO] Finished at: 2022-12-22T16:02:23-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.18:test (native-test) on project demo: Execution of C:\Program Files\BellSoft\LibericaNIK-Full-22-OpenJDK-17\bin\native-image.cmd @target\tmp\native-image-5826493397404161278.args returned non-zero result -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Java version:

java --version

openjdk 17.0.5 2022-10-18 LTS
OpenJDK Runtime Environment GraalVM 22.3.0 (build 17.0.5+8-LTS)
OpenJDK 64-Bit Server VM GraalVM 22.3.0 (build 17.0.5+8-LTS, mixed mode, sharing)

Maven version:

mvn --version

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: C:\Users\ricsfd\apache-maven-3.8.6
Java version: 17.0.5, vendor: BellSoft, runtime: C:\Program Files\BellSoft\LibericaNIK-Full-22-OpenJDK-17
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>3.0.0</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.example</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo</name>
	<description>Demo project for Spring Boot</description>
	<properties>
		<java.version>17</java.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.graalvm.buildtools</groupId>
				<artifactId>native-maven-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

</project>

Is this a known behavior/bug?

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions