graalvm / native-build-tools

Native-image plugins for various build tools
https://graalvm.github.io/native-build-tools/
Other
349 stars 51 forks source link

0.9.26 and 0.9.27 are not compatible with Graal 22.3 #516

Closed wilkinsona closed 9 months ago

wilkinsona commented 9 months ago

Describe the bug

Upgrading the NBT plugin to 0.9.26 or 0.9.27 causes a project that previously built successfully to fail due to --color being an unrecognised option:

> Task :data:data-jpa:nativeCompile FAILED
[native-image-plugin] GraalVM Toolchain detection is disabled
[native-image-plugin] GraalVM location read from environment variable: JAVA_HOME
[native-image-plugin] Native Image executable path: /Users/awilkinson/.sdkman/candidates/java/22.3.2.r17-nik/lib/svm/bin/native-image
Error: Unrecognized option: --color

I think the problem was introduced by https://github.com/graalvm/native-build-tools/commit/c02c2053175b351ad2ec2acd8d037b82900b31e5.

To Reproduce

Run the nativeCompile task in a Gradle project using NBT 0.9.26 or .27.

Expected behavior

--color is not added to the command line options of a native-image binary that does not support it.

fniephaus commented 9 months ago

Thanks for raising this. The problem is that the regular expression to extract the major version also matches the old version format and then returns 22. We should probably refine getMajorJDKVersion so that is also matches the old version scheme correct. For the following, for example, it should return 17:

~/.sdkman/candidates/java/22.3.2.r17-nik/bin/native-image --version
GraalVM 22.3.2 Java 17 CE (Java Version 17.0.7+7-LTS)