micronaut-projects / micronaut-maven-plugin

Maven plugin to execute Micronaut applications
https://micronaut-projects.github.io/micronaut-maven-plugin/latest/
Apache License 2.0
21 stars 22 forks source link

How to specify GRAALVM version in Maven #1188

Open padetiloye opened 2 months ago

padetiloye commented 2 months ago

Issue description

I need to use the graalvm version 22.2 in maven but I've no clue where to set it in the pom.xml.

https://www.graalvm.org/release-notes/22_2/

Is there a micronaut version that support graalvm version 22.2 yet ?

Any suggestion ?

yawkat commented 2 months ago

You can just run the build using that version as your JAVA_HOME eg using sdkman

padetiloye commented 2 months ago

@yawkat - it doesn't use your JAVA_HOME installation. The version of JVM used inside the docker container is different from local installation.

Changing the jdk.version in the pom file changes GRAALVM_JVM_VERSION to 22 but does not allow to build a native image with the error

 To build native images you must set the Java target byte code level to Java 21 or below

All attempt to change GRAALVM_JVM_VERSION variable didn't work and kept the jdk.version in the pom file.

[INFO] --- mn:4.6.1:docker-native (default-docker-native) @ game-stats --- [INFO] Using GRAALVM_JVM_VERSION: 17 [INFO] Using GRAALVM_ARCH: x64 [INFO] Using CLASS_NAME: com.wba.tokenization.FunctionLambdaRuntime

The only walkaround for us is to build the native image using the customize Dockerfile generated by the plugin.

Generate a dockerfile from micronaut app

 mvn mn:dockerfile -Dpackaging=docker-native -Dmicronaut.runtime=lambda

and now, do

mvn package -Dpackaging=docker -Dmicronaut.runtime=lambda -Pgraalvm

This is cumbersome to just change the GRAALVM_JVM_VERSION