From bc9bb38ebefb2920daf0af13b3593d200a293a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Galder=20Zamarren=CC=83o?= Date: Tue, 25 Jan 2022 11:39:09 +0100 Subject: [PATCH] Add docu to handle Java preview features for building natives --- .../main/asciidoc/building-native-image.adoc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/src/main/asciidoc/building-native-image.adoc b/docs/src/main/asciidoc/building-native-image.adoc index 59eeac2a19647..5c1edac535b1c 100644 --- a/docs/src/main/asciidoc/building-native-image.adoc +++ b/docs/src/main/asciidoc/building-native-image.adoc @@ -220,6 +220,15 @@ cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\ In addition to the regular files, the build also produces `target/getting-started-1.0.0-SNAPSHOT-runner`. You can run it using: `./target/getting-started-1.0.0-SNAPSHOT-runner`. +[[graal-package-preview]] +[NOTE] +.Java preview features +==== +Java code that relies on preview features requires special attention. +To produce a native executable, this means that the `--enable-preview` flag needs to be passed to the underlying native image invocation. +You can do so by prepending the flag with `-J` and passing it as additional native build argument: `-Dquarkus.native.additional-build-args=-J--enable-preview`. +==== + == Testing the native executable Producing a native executable can lead to a few issues, and so it's also a good idea to run some tests against the application running in the native file. @@ -319,6 +328,15 @@ Alternatively, you can run your tests with: `./mvnw verify -Pnative -Dquarkus.te However, don't forget that when the native executable is built the `prod` profile is enabled. So, the profile you enable this way must be compatible with the produced executable. +[[graal-test-preview]] +[NOTE] +.Java preview features +==== +Java code that relies on preview features requires special attention. +To test a native executable, this means that the `--enable-preview` flag needs to be passed to the Surefire plugin. +Adding `--enable-preview` to its `configuration` section is one way to do so. +==== + === Excluding tests when running as a native executable When running tests this way, the only things that actually run natively are you application endpoints, which