From d21fb3699e0661cd0f7830cdcc1f49090bba3ee7 Mon Sep 17 00:00:00 2001 From: Betty Mann Date: Tue, 2 Sep 2025 16:28:34 +0100 Subject: [PATCH 1/2] Move JUnit tests to get started --- .../asciidoc/end-to-end-gradle-guide.adoc | 66 ++++++------- .../docs/asciidoc/end-to-end-maven-guide.adoc | 98 +++++++++---------- 2 files changed, 82 insertions(+), 82 deletions(-) diff --git a/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc b/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc index e2f57a313..3b9ee6587 100644 --- a/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc +++ b/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc @@ -55,7 +55,38 @@ This command will compile your application and create a native executable in the ./gradlew nativeRun ---- -Continue reading below to learn more about the plugin. +Continue to advanced use cases to learn more about the plugin. + +[[run-junit-tests]] +=== Run Junit Tests + +This plugin supports running tests on the JUnit Platform. +The tests are compiled ahead of time and executed as native code. + +- Add the JUnit 5 dependency to _build.gradle_ / _build.gradle.kts_ to include the testing framework: + +[source,groovy,role="multi-language-sample"] +---- +testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' +testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' +testImplementation 'junit:junit:4.13.2' +---- + +[source,kotlin,role="multi-language-sample"] +---- +testImplementation('org.junit.jupiter:junit-jupiter-api:5.8.1') +testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.8.1') +testImplementation('junit:junit:4.13.2') +---- + +- Run the tests: + +[source,bash,role="multi-language-sample"] +---- +./gradlew nativeTest +---- + +The tests are compiled ahead of time and executed as native code. [[advanced-use-cases]] == Advanced Use Cases: How to @@ -134,37 +165,6 @@ This works similarly to `JAVA_TOOL_OPTIONS`, where the value of the environment Learn more about Native Image build configuration https://www.graalvm.org/reference-manual/native-image/overview/BuildConfiguration/[on the website]. -[[run-junit-tests]] -=== Run Junit Tests - -This plugin supports running tests on the JUnit Platform. -The tests are compiled ahead of time and executed as native code. - -- Add the JUnit 5 dependency to _build.gradle_ / _build.gradle.kts_ to include the testing framework: - -[source,groovy,role="multi-language-sample"] ----- -testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' -testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' -testImplementation 'junit:junit:4.13.2' ----- - -[source,kotlin,role="multi-language-sample"] ----- -testImplementation('org.junit.jupiter:junit-jupiter-api:5.8.1') -testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.8.1') -testImplementation('junit:junit:4.13.2') ----- - -- Run the tests: - -[source,bash,role="multi-language-sample"] ----- -./gradlew nativeTest ----- - -The tests are compiled ahead of time and executed as native code. - [[gather-execution-profiles]] === Gather Execution Profiles and Build Optimized Images @@ -444,4 +444,4 @@ All the monitoring and debugging tools https://www.graalvm.org/reference-manual/ === Learn more -To continue learning, refer to the <>. \ No newline at end of file +To continue learning, refer to the <>. \ No newline at end of file diff --git a/docs/src/docs/asciidoc/end-to-end-maven-guide.adoc b/docs/src/docs/asciidoc/end-to-end-maven-guide.adoc index 0ebb621fb..e1f7bb546 100644 --- a/docs/src/docs/asciidoc/end-to-end-maven-guide.adoc +++ b/docs/src/docs/asciidoc/end-to-end-maven-guide.adoc @@ -103,54 +103,6 @@ This command will compile your application and create a native executable in the You can have multiple profiles, which is very convenient if you want to produce different versions of your native images for your application (optimized, static, and others). Continue to advanced use cases to learn more. -[[advanced-use-cases]] -== Advanced Use Cases: How to - -For advanced use cases, this guide provides instructions for configuring the build process, running tests on native code, gathering execution profiles, troubleshooting missing configuration, and enabling diagnostic tools to analyze native images. - -[[configure-image-build]] -=== Configure Native Image Build - -The plugin supports passing options directly to Native Image inside the `` block. -Using ``, you can pass any Native Image build option listed on https://www.graalvm.org/reference-manual/native-image/overview/Options/[this page]. - -The plugin also provides special properties to configure the build: - -- `` - Sets the environment options -- `` - Specifies of the name for the native executable file. If a custom name is not supplied, the artifact ID of the project will be used by default (defaults to the project name). -- `` - Passes the given argument directly to the JVM running the `native-image` tool -- `` - Enables quick build mode -- `` - Enables the verbose output -- and many more https://graalvm.github.io/native-build-tools/latest/maven-plugin.html#configuration-options[listed here]. - -Here is an example of additional options usage: -[source,xml, role="multi-language-sample"] ----- - - org.example.Main - myApp - true - - -O3 - - - value1 - value2 - - - your-argument - - ----- - -[TIP] -==== -As an alternative, you can pass additional build options via the `NATIVE_IMAGE_OPTIONS` environment variable, on the command line. -This works similarly to `JAVA_TOOL_OPTIONS`, where the value of the environment variable is prefixed to the options supplied to `native-image`. -==== - -Learn more about Native Image build configuration https://www.graalvm.org/reference-manual/native-image/overview/BuildConfiguration/[on the website]. - [[run-junit-tests]] === Run Junit Tests @@ -232,6 +184,54 @@ Alternatively, set `` to `true` in the plugin configuration: This way you configure your Maven profile to skip generation and execution of tests as native code. +[[advanced-use-cases]] +== Advanced Use Cases: How to + +For advanced use cases, this guide provides instructions for configuring the build process, running tests on native code, gathering execution profiles, troubleshooting missing configuration, and enabling diagnostic tools to analyze native images. + +[[configure-image-build]] +=== Configure Native Image Build + +The plugin supports passing options directly to Native Image inside the `` block. +Using ``, you can pass any Native Image build option listed on https://www.graalvm.org/reference-manual/native-image/overview/Options/[this page]. + +The plugin also provides special properties to configure the build: + +- `` - Sets the environment options +- `` - Specifies of the name for the native executable file. If a custom name is not supplied, the artifact ID of the project will be used by default (defaults to the project name). +- `` - Passes the given argument directly to the JVM running the `native-image` tool +- `` - Enables quick build mode +- `` - Enables the verbose output +- and many more https://graalvm.github.io/native-build-tools/latest/maven-plugin.html#configuration-options[listed here]. + +Here is an example of additional options usage: +[source,xml, role="multi-language-sample"] +---- + + org.example.Main + myApp + true + + -O3 + + + value1 + value2 + + + your-argument + + +---- + +[TIP] +==== +As an alternative, you can pass additional build options via the `NATIVE_IMAGE_OPTIONS` environment variable, on the command line. +This works similarly to `JAVA_TOOL_OPTIONS`, where the value of the environment variable is prefixed to the options supplied to `native-image`. +==== + +Learn more about Native Image build configuration https://www.graalvm.org/reference-manual/native-image/overview/BuildConfiguration/[on the website]. + [[gather-execution-profiles]] === Gather Execution Profiles and Build Optimized Images @@ -500,4 +500,4 @@ You will find the output of these tools among the generated artifacts after runn === Learn more -To continue learning, refer to the <>. \ No newline at end of file +To continue learning, refer to the <>. \ No newline at end of file From fbe1e97bf19e9808006c2f2ad8a8c4e29ad29583 Mon Sep 17 00:00:00 2001 From: Betty Mann Date: Tue, 23 Sep 2025 10:00:34 +0100 Subject: [PATCH 2/2] Update docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc --- docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc b/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc index 3b9ee6587..b15c811ec 100644 --- a/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc +++ b/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc @@ -55,7 +55,6 @@ This command will compile your application and create a native executable in the ./gradlew nativeRun ---- -Continue to advanced use cases to learn more about the plugin. [[run-junit-tests]] === Run Junit Tests