### Example Reachability Metadata Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/maven-plugin.adoc An example of a generated reachability metadata file, showing reflection, resources, bundles, and JNI configurations. ```json { "reflection": [ { "condition": { "typeReached": "java.util.concurrent.atomic.AtomicBoolean" }, "type": "java.util.concurrent.atomic.AtomicBoolean", "fields": [ { "name": "value" } ] }, { "condition": { "typeReached": "org.apache.maven.surefire.booter.ForkedBooter" }, "type": "org.apache.maven.surefire.booter.spi.LegacyMasterProcessChannelProcessorFactory" }, { "condition": { "typeReached": "org.apache.maven.surefire.booter.ForkedBooter" }, "type": "org.apache.maven.surefire.booter.spi.SurefireMasterProcessChannelProcessorFactory" }, { "condition": { "typeReached": "org.junit.platform.launcher.core.DefaultLauncher" }, "type": "org.apiguardian.api.API" }, { "condition": { "typeReached": "java.lang.Class" }, "type": "org.example.NativeTests" }, { "condition": { "typeReached": "java.util.Collections$2" }, "type": "org.example.NativeTests" }, { "condition": { "typeReached": "org.apache.maven.surefire.api.util.DefaultScanResult" }, "type": "org.example.NativeTests" }, { "condition": { "typeReached": "org.junit.jupiter.engine.JupiterTestEngine" }, "type": "org.example.NativeTests" }, { "condition": { "typeReached": "org.junit.jupiter.engine.discovery.ClassSelectorResolver$$Lambda/0x00007a5c0f03fbb8" }, "type": "org.example.NativeTests" }, { "condition": { "typeReached": "java.security.Provider$Service" }, "type": "sun.security.provider.SHA", "methods": [ { "name": "", "parameterTypes": [] } ] } ... ], "resources": [ { "condition": { "typeReached": "jdk.internal.logger.BootstrapLogger$DetectBackend$1" }, "glob": "META-INF/services/java.lang.System$LoggerFinder" }, { "condition": { "typeReached": "jdk.internal.logger.LoggerFinderLoader" }, "glob": "META-INF/services/java.lang.System$LoggerFinder" }, { "condition": { "typeReached": "org.apache.maven.surefire.booter.ForkedBooter" }, "glob": "META-INF/services/org.apache.maven.surefire.spi.MasterProcessChannelProcessorFactory" }, { "condition": { "typeReached": "java.lang.ClassLoader" }, "glob": "TestResource.txt" }, ... ], "bundles": [], "jni": [ { "condition": { "typeReached": "sun.nio.ch.IOUtil" }, "type": "java.lang.Boolean", "methods": [ { "name": "getBoolean", "parameterTypes": [ "java.lang.String" ] } ] }, { "condition": { "typeReached": "sun.management.VMManagementImpl" }, "type": "sun.management.VMManagementImpl", "fields": [ { "name": "compTimeMonitoringSupport" }, { "name": "currentThreadCpuTimeSupport" }, { "name": "objectMonitorUsageSupport" }, { "name": "otherThreadCpuTimeSupport" }, { "name": "remoteDiagnosticCommandsSupport" }, { "name": "synchronizerUsageSupport" }, { "name": "threadAllocatedMemorySupport" }, { "name": "threadContentionMonitoringSupport" } ] } ] } ``` -------------------------------- ### Common Native Image Build Commands Source: https://github.com/graalvm/native-build-tools/blob/master/native-maven-plugin/docs/functional/native-image-builds.md Provides examples of common Maven commands for various native image build tasks, including lifecycle builds, direct compilation, testing, argument file generation, and metadata reporting. ```bash mvn -Pnative -DquickBuild -DskipTests package ``` ```bash mvn -Pnative native:compile ``` ```bash mvn -Pnative -DquickBuild native:test ``` ```bash mvn -Pnative native:write-args-file ``` ```bash mvn -Pnative native:list-libraries-missing-metadata ``` -------------------------------- ### Example Maven Command-Line Properties Source: https://github.com/graalvm/native-build-tools/blob/master/native-maven-plugin/docs/functional/configuration-model.md Demonstrates overriding build configurations using Maven command-line properties for temporary runs. These properties feed into the same option state as XML configuration. ```bash mvn -Pnative -DquickBuild -Dverbose -DskipTests package ``` -------------------------------- ### Complete Agent Configuration (Kotlin DSL) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc A comprehensive example of the agent configuration block using Kotlin DSL. This includes default mode, enabled status, conditional and direct modes, filter files, and metadata copy settings. ```kotlin agent { defaultMode.set("standard") enabled.set(true) modes { conditional { userCodeFilterPath.set("path-to-filter.json") extraFilterPath.set("path-to-another-filter.json") } direct { options.add("config-output-dir={output_dir}") options.add("experimental-configuration-with-origins") } } callerFilterFiles.from("filter.json") accessFilterFiles.from("filter.json") builtinCallerFilter.set(true) builtinHeuristicFilter.set(true) enableExperimentalPredefinedClasses.set(false) enableExperimentalUnsafeAllocationTracing.set(false) trackReflectionMetadata.set(true) metadataCopy { inputTaskNames.add("test") outputDirectories.add("src/main/resources/META-INF/native-image///") mergeWithExisting.set(true) } } ``` -------------------------------- ### Complete Agent Configuration (Groovy DSL) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc A comprehensive example of the agent configuration block using Groovy DSL. This includes default mode, enabled status, conditional and direct modes, filter files, and metadata copy settings. ```groovy agent { defaultMode = "standard" enabled = true modes { conditional { userCodeFilterPath = "path-to-filter.json" extraFilterPath = "path-to-another-filter.json" } direct { options.add("config-output-dir={output_dir}") options.add("experimental-configuration-with-origins") } } callerFilterFiles.from("filter.json") accessFilterFiles.from("filter.json") builtinCallerFilter = true builtinHeuristicFilter = true enableExperimentalPredefinedClasses = false enableExperimentalUnsafeAllocationTracing = false trackReflectionMetadata = true metadataCopy { inputTaskNames.add("test") outputDirectories.add("src/main/resources/META-INF/native-image///") mergeWithExisting = true } } ``` -------------------------------- ### Building and Publishing JUnit Platform Native Artifact Source: https://github.com/graalvm/native-build-tools/blob/master/common/junit-platform-native/README.md This command builds the project and publishes the latest artifact to the local Maven repository. Ensure GraalVM with `native-image` is installed and `$GRAALVM_HOME` is set. ```bash ./gradlew publishToMavenLocal ``` -------------------------------- ### Configure Native Image Build Options (Groovy) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc Configure GraalVM Native Image build options within the graalvmNative block in build.gradle. This example sets verbose mode, custom image name, main class, and an optimization flag. ```groovy graalvmNative { binaries.all { // common options verbose = true } binaries.main { // options to configure the main binary imageName = 'myApp' mainClass = 'org.example.Main' buildArgs.add('-O3') // enables additional compiler optimizations } } ``` -------------------------------- ### Configure Custom Native Test Binary in Gradle (Kotlin) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc Register a new native test binary for a custom test source set. This enables running specific test suites as native binaries, similar to the 'integTest' example. ```kotlin graalvmNative.registerNativeTest("custom") ``` -------------------------------- ### All Native Image Configuration Options (Kotlin) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc Demonstrates various configuration options for building native images in Kotlin. ```kotlin graalvmNative { // options for the main binary binaries.main { imageName = "my-app" mainClass = "com.example.MainClass" debug = true verbose = true fallback = true sharedLibrary = true quickBuild = true richOutput = true systemProperties.add("a=b") systemProperties.add("c=d") configurationFileDirectories.add("dir1") configurationFileDirectories.add("dir2") excludeConfig.add("com.example:my-lib:1.0:reflection") jvmArgs.add("-Xmx4g") jvmArgs.add("-XX:MaxDirectMemorySize=1g") useFatJar = true } // options for the test binary binaries.test { imageName = "my-test-app" mainClass = "com.example.MainTestClass" debug = false verbose = false fallback = false sharedLibrary = false quickBuild = false richOutput = false systemProperties.add("e=f") configurationFileDirectories.add("testDir1") excludeConfig.add("com.example:my-lib:1.0:reflection") jvmArgs.add("-Xmx2g") useFatJar = false } // common options for both main and test binaries binaries.all { imageName = "default-app-name" mainClass = "com.example.DefaultMainClass" debug = false verbose = false fallback = false sharedLibrary = false quickBuild = false richOutput = false systemProperties.clear() configurationFileDirectories.clear() excludeConfig.clear() jvmArgs.clear() useFatJar = false } } ``` -------------------------------- ### Generated Reachability Metadata Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/maven-plugin.adoc Example of a reachability-metadata.json file after updating filters, showing reflection and resource configurations. ```json { "reflection": [ { "condition": { "typeReached": "org.example.NativeTests" }, "type": "org.example.NativeTests$Person", "allDeclaredFields": true } ], "resources": [ { "condition": { "typeReached": "org.example.NativeTests" }, "glob": "TestResource.txt" } ], "bundles": [] } ``` -------------------------------- ### All Native Image Configuration Options (Groovy) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc Demonstrates various configuration options for building native images in Groovy. ```groovy graalvmNative { // options for the main binary binaries.main { imageName = "my-app" mainClass = "com.example.MainClass" debug = true verbose = true fallback = true sharedLibrary = true quickBuild = true richOutput = true systemProperties = ["a=b", "c=d"] configurationFileDirectories = ["dir1", "dir2"] excludeConfig = ["com.example:my-lib:1.0:reflection"] jvmArgs = ["-Xmx4g", "-XX:MaxDirectMemorySize=1g"] useFatJar = true } // options for the test binary binaries.test { imageName = "my-test-app" mainClass = "com.example.MainTestClass" debug = false verbose = false fallback = false sharedLibrary = false quickBuild = false richOutput = false systemProperties = ["e=f"] configurationFileDirectories = ["testDir1"] excludeConfig = ["com.example:my-lib:1.0:reflection"] jvmArgs = ["-Xmx2g"] useFatJar = false } // common options for both main and test binaries binaries.all { imageName = "default-app-name" mainClass = "com.example.DefaultMainClass" debug = false verbose = false fallback = false sharedLibrary = false quickBuild = false richOutput = false systemProperties = [] configurationFileDirectories = [] excludeConfig = [] jvmArgs = [] useFatJar = false } } ``` -------------------------------- ### Maven Plugin: Reusing Build Arguments from Parent POM Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/maven-plugin.adoc Example of a parent POM defining build arguments for the native-maven-plugin. ```xml org.graalvm.buildtools native-maven-plugin ${current_plugin_version} ${project.artifactId} ${exec.mainClass} --no-fallback ``` -------------------------------- ### Enable Quick Build Mode for Faster Builds Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/maven-plugin.adoc Set `` to `true` to utilize quick build mode for faster native image generation. Alternatively, set the `GRAALVM_QUICK_BUILD` environment variable to `true`. ```xml true ``` -------------------------------- ### Maven Plugin: Appending Build Arguments in Child POM Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/maven-plugin.adoc Example of a child POM appending build arguments to the native-maven-plugin configuration inherited from a parent POM. ```xml org.graalvm.buildtools native-maven-plugin --verbose ``` -------------------------------- ### Full Build and Test Source: https://github.com/graalvm/native-build-tools/blob/master/DEVELOPING.md Perform a complete build and run all tests. This command can be very time-consuming. ```bash ./gradlew build ``` -------------------------------- ### Maven Plugin Agent Configuration Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/maven-plugin.adoc Configure the native image agent in your Maven POM file. This example shows various options for agent modes and settings. ```xml true standard true true /path/to/filter.json true ``` -------------------------------- ### Enable Toolchain Detection (Kotlin) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc Enable Gradle toolchain support for GraalVM in your build.gradle.kts file using Kotlin. This is recommended only if GraalVM is the sole JDK installed. ```kotlin include::../snippets/gradle/kotlin/build.gradle.kts[tags=enabling-toolchain, indent=0] ``` -------------------------------- ### Compile All Projects Source: https://github.com/graalvm/native-build-tools/blob/master/DEVELOPING.md Use this command to compile all projects within the repository. ```bash ./gradlew assemble ``` -------------------------------- ### Enable Toolchain Detection (Groovy) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc Enable Gradle toolchain support for GraalVM in your build.gradle file using Groovy. This is recommended only if GraalVM is the sole JDK installed. ```groovy include::../snippets/gradle/groovy/build.gradle[tags=enabling-toolchain, indent=0] ``` -------------------------------- ### Declare Extra Source Set for Native Image Dependencies (Kotlin) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc Example of declaring an extra source set in Kotlin for dependencies that are only required during native image compilation. ```kotlin sourceSets { main { java { srcDirs(listOf("src/main/java", "src/main/native-java")) } } } dependencies { nativeImageCompileOnly("org.graalvm.sdk:graalvm-sdk") nativeImageCompileOnly("org.graalvm.nativeimage:native-image-maven-plugin") } ``` -------------------------------- ### Basic Native Image Configuration Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/maven-plugin.adoc Configure basic settings for a native image build, including image name, main class, fallback behavior, and verbosity. ```xml myapp org.example.ClassName false true ``` -------------------------------- ### Declare Extra Source Set for Native Image Dependencies (Groovy) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc Example of declaring an extra source set in Groovy for dependencies that are only required during native image compilation. ```groovy sourceSets { main { java { srcDirs = ["src/main/java", "src/main/native-java"] } } } dependencies { nativeImageCompileOnly("org.graalvm.sdk:graalvm-sdk") nativeImageCompileOnly("org.graalvm.nativeimage:native-image-maven-plugin") } ``` -------------------------------- ### Add Maven Assembly Plugin to Native Profile Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/maven-plugin.adoc Configure the Maven Assembly plugin within the 'native' profile in your pom.xml. This setup is required for packaging tests with dependencies. ```xml native org.apache.maven.plugins maven-assembly-plugin 3.3.0 true src/assembly/test-jar-with-dependencies.xml test-jar-with-dependencies package single ``` -------------------------------- ### Enable Tracing Agent and Copy Metadata via Command Line Source: https://github.com/graalvm/native-build-tools/blob/master/native-maven-plugin/docs/functional/tracing-agent.md Use command-line properties to enable the tracing agent for tests and then invoke the metadata copy goal. ```bash mvn -Pnative -Dagent=true test ``` ```bash mvn -Pnative native:metadata-copy ``` -------------------------------- ### Configure metadataCopy Task in pom.xml Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/end-to-end-maven-guide.adoc Configure the metadataCopy task to collect and copy generated metadata to the resources directory. This example disables metadata copy for the 'main' stage and enables merging. ```xml true main true src/test/resources/META-INF/native-image ``` -------------------------------- ### Compile Native Image with Overrides Source: https://github.com/graalvm/native-build-tools/blob/master/native-gradle-plugin/docs/functional/native-image-tasks.md Demonstrates how to override native image compilation options directly from the command line. Use these for quick experimentation without modifying build scripts. ```bash ./gradlew nativeCompile --quick-build-native --verbose --image-name demo-dev ``` ```bash ./gradlew nativeCompile --build-args=--initialize-at-build-time=com.example ``` ```bash ./gradlew nativeCompile --force-build-args=--no-fallback ``` -------------------------------- ### Build Native Image with Metadata Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc Execute this Gradle task to build the native image, ensuring metadata is included. ```bash ./gradlew metadataCopy ``` -------------------------------- ### Configure GraalVM Native Binary Source: https://github.com/graalvm/native-build-tools/blob/master/native-gradle-plugin/docs/functional/plugin-model.md Configure a 'main' binary for a typical application, setting its image name, build arguments, and enabling quick build. ```groovy graalvmNative { binaries { main { imageName = 'demo' buildArgs.add('--verbose') quickBuild = true } } } ``` -------------------------------- ### Run Gradle with Specific Agent Mode Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc Execute Gradle tasks with the tracing agent enabled and specify the agent mode directly on the command line. Examples include 'standard', 'conditional', and 'direct' modes for the `nativeTest` task. ```bash ./gradlew -Pagent=standard nativeTest ./gradlew -Pagent=conditional nativeTest ./gradlew -Pagent=direct nativeTest ``` -------------------------------- ### Configure Native Image Build (Groovy) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/changelog.adoc Configure native image builds using the `graalvmNative.binaries.main` block. This is the recommended approach for setting options like verbosity. ```groovy graalvmNative { binaries { main { verbose = true } } } ``` -------------------------------- ### Build Instrumented Native Image for PGO Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc Build a native image with PGO instrumentation enabled using Gradle. ```bash ./gradlew nativeCompile --pgo-instrument ``` -------------------------------- ### Configure Native Image Binaries Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc Configure the main, test, and all binaries for native image generation using the graalvmNative extension. ```groovy graalvmNative { binaries.main { // options for the main binary } binaries.test { // options for the test binary } binaries.all { // common options for both main and test binaries } } ``` -------------------------------- ### Native Maven Plugin Lifecycle Binding Example Source: https://github.com/graalvm/native-build-tools/blob/master/native-maven-plugin/docs/functional/goal-surface.md Configure the native-maven-plugin to bind the compile-no-fork goal to the package phase within a Maven profile. This allows for building a native image alongside regular Maven outputs when the profile is activated. ```xml native org.graalvm.buildtools native-maven-plugin ${native.maven.plugin.version} true build-native compile-no-fork package demo com.example.Main false --verbose ``` -------------------------------- ### Build and Test Native Images via Maven Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/announcement.adoc Commands to trigger native image builds and testing using the configured Maven profile. ```shell mvn -Pnative -DskipTests package ``` ```shell mvn -Pnative test ``` -------------------------------- ### Run Native Executable Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/end-to-end-maven-guide.adoc Execute the application from the generated native executable. This command assumes the executable is named 'myApp' and is located in the target directory. ```bash ./target/myApp ``` -------------------------------- ### Run Agent and Copy Metadata Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/end-to-end-maven-guide.adoc Execute the Maven command to run the agent for metadata collection and then copy the metadata using the native:metadata-copy goal. ```bash ./mvnw -Pnative test native:metadata-copy ``` -------------------------------- ### Execute Native Application with Generated Configuration Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/maven-plugin.adoc Run your native application using the configuration files previously generated by the agent. This command ensures the application uses the collected metadata. ```bash ./mvnw -Pnative -Dagent=true -DskipTests package exec:exec@native ``` -------------------------------- ### Configure Native Build with GraalVM (Groovy) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/changelog.adoc Deprecated configuration for `nativeBuild`. Use the `graalvmNative.binaries.main` block for configuring native image builds with verbose output. ```groovy nativeBuild { verbose = true } ``` -------------------------------- ### Build Native Image Gradle Plugin Source: https://github.com/graalvm/native-build-tools/blob/master/native-gradle-plugin/README.md Builds the Native Image Gradle plugin and publishes snapshot artifacts to a common repository. Use this command from the root directory of the project. ```bash ./gradlew :native-gradle-plugin:publishAllPublicationsToCommonRepository --no-parallel ``` -------------------------------- ### Use Pre-release Version (Kotlin) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc Configure your settings.gradle.kts file to use a snapshot repository for development versions of the GraalVM Native plugin in Kotlin. ```kotlin include::../snippets/gradle/kotlin/settings.gradle.kts[tags=pre-release, indent=0] ``` -------------------------------- ### Compile and run native tests Source: https://github.com/graalvm/native-build-tools/blob/master/native-gradle-plugin/docs/functional/native-tests.md Use the `nativeTest` Gradle task to compile the test image, execute it, and report failures through Gradle. This is the recommended task for CI environments. ```bash ./gradlew nativeTest ``` -------------------------------- ### Generate and Run Instrumented Native Image with Gradle Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc Use a single Gradle command to both generate and run the instrumented native image, automatically storing the profile data. ```bash ./gradlew nativeCompile --pgo-instrument nativeRun ``` -------------------------------- ### Run Native Executable with Gradle Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc Use the nativeRun task to execute your application's native binary. ```bash ./gradlew nativeRun ``` -------------------------------- ### Build Native Maven Plugin Source: https://github.com/graalvm/native-build-tools/blob/master/native-maven-plugin/README.md Builds the Native Image Maven Plugin and publishes a snapshot to the common repository. Requires Gradle wrapper. ```bash ./gradlew :native-maven-plugin:publishAllPublicationsToCommonRepository --no-parallel ``` -------------------------------- ### Configure Native Image Build with Kotlin Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc Configure build arguments and debugging options for native images using Kotlin syntax in Gradle. ```kotlin graalvmNative { binaries.all { buildArgs.add('--emit build-report') buildArgs.add('--enable-monitoring=jfr') debug.set(true) } } ``` -------------------------------- ### Configure Native Image Build with Groovy Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc Configure build arguments and debugging options for native images using Groovy syntax in Gradle. ```groovy graalvmNative { binaries.all { buildArgs.add('--emit build-report') buildArgs.add('--enable-monitoring=jfr') debug = true } } ``` -------------------------------- ### Apply Java and GraalVM Native Plugins Source: https://github.com/graalvm/native-build-tools/blob/master/native-gradle-plugin/docs/functional/plugin-model.md Apply the 'application' plugin and the 'org.graalvm.buildtools.native' plugin. Configure the main class for the application. ```groovy plugins { id 'application' id 'org.graalvm.buildtools.native' } application { mainClass.set('com.example.Main') } ``` -------------------------------- ### Use Argument File for Native Image Building Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/maven-plugin.adoc Set `` to `true` to enable the use of an argument file for native image building. This can help manage complex build configurations. ```xml true ``` -------------------------------- ### Run Checkstyle Source: https://github.com/graalvm/native-build-tools/blob/master/DEVELOPING.md Execute Checkstyle for main and test sources in specific projects. ```bash ./gradlew :graalvm-reachability-metadata:checkstyleMain :graalvm-reachability-metadata:checkstyleTest ``` ```bash ./gradlew :junit-platform-native:checkstyleMain :junit-platform-native:checkstyleTest ``` -------------------------------- ### Build Native Executable with Maven Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/end-to-end-maven-guide.adoc Instructs the Maven plugin to package the project as a native executable. This command can be used to generate artifacts that include monitoring and debugging tools. ```bash ./mvnw -Pnative package ``` -------------------------------- ### Clean All Projects Source: https://github.com/graalvm/native-build-tools/blob/master/DEVELOPING.md Use this command to clean all projects in the repository. ```bash ./gradlew clean ``` -------------------------------- ### List Libraries Missing Metadata (Gradle) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/index.adoc Use this command to check which direct dependencies are unsupported by the reachability metadata repository before manual troubleshooting. ```bash ./gradlew listLibrariesMissingMetadata ``` -------------------------------- ### Configure Additional Test Suites in Gradle (Groovy) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc Register a new native test binary for an additional test source set, such as 'integTest'. This allows running custom test suites as native binaries. ```groovy graalvmNative.registerNativeTest("integTest") ``` -------------------------------- ### Configure Build Arguments for Native Image Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/maven-plugin.adoc Use the `` tag to pass additional build options to the `native-image` command. This allows customization of the native image generation process. ```xml --argument ``` -------------------------------- ### Run Native Tests with Gradle Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc Execute tests compiled and run as native code using the Gradle wrapper. This command triggers the native test execution process. ```bash ./gradlew nativeTest ``` -------------------------------- ### Enable Tracing Agent via Command Line Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc Run Gradle with the `-Pagent` option to attach the tracing agent for a specific execution. This is useful for collecting metadata during application runs. ```bash ./gradlew -Pagent run ``` -------------------------------- ### Use Pre-release Version (Groovy) Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/gradle-plugin.adoc Configure your settings.gradle file to use a snapshot repository for development versions of the GraalVM Native plugin in Groovy. ```groovy include::../snippets/gradle/groovy/settings.gradle[tags=pre-release, indent=0] ``` -------------------------------- ### Execute Java Application with Agent Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/maven-plugin.adoc Run your Java application with the agent attached, skipping tests and native build, by using the 'exec:exec@java-agent' goal. Configuration files are generated in 'target/native/agent-output/main'. ```bash ./mvnw -Pnative -Dagent=true -DskipTests -DskipNativeBuild=true package exec:exec@java-agent ``` -------------------------------- ### Build Native Executable with Gradle Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc Use the nativeCompile task to build a native executable of your application. ```bash ./gradlew nativeCompile ``` -------------------------------- ### Build Instrumented Native Image for PGO Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/end-to-end-maven-guide.adoc Build an instrumented native image using the --pgo-instrument build argument to gather profiling data for optimization. ```xml --pgo-instrument myApp-instrumented ``` -------------------------------- ### Run Instrumented Executable Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/end-to-end-maven-guide.adoc Execute the instrumented application to generate profile data. ```bash ./target/instrumentedApp ``` -------------------------------- ### Run Tests and Metadata Copy Task Source: https://github.com/graalvm/native-build-tools/blob/master/docs/src/docs/asciidoc/maven-plugin.adoc Combine running tests with the agent and executing the 'metadataCopy' task by appending 'native:metadata-copy' to the command. ```bash ./mvnw -Pnative -Dagent=true test native:metadata-copy ```