Home > Blockchain >  How to include a resource in micronaut graalvm native image with gradle buildNativeLambda
How to include a resource in micronaut graalvm native image with gradle buildNativeLambda

Time:01-10

As described in this guide I am using ./gradlew buildNativeLambda command to generate zip file containing graalvm native image. I am facing a problem described in this thread so wanted to include resource by passing -H:IncludeResources to my command like below:

./gradlew buildNativeLambda -H:IncludeResources="com/amazonaws/partitions/endpoints.json"

Unfortunately, its failing with Unknown command-line option '-H'. How can I pass this to gradle task?

CodePudding user response:

-H:IncludeResources is supposed to be used with Native Image builder utility like this:

native-image -H:IncludeResources=<Java regexp that matches resources to be included in the image>

as described here: https://www.graalvm.org/reference-manual/native-image/Resources/

If you haven't installed native-image, run gu install native-image as described here: https://www.graalvm.org/reference-manual/native-image/#install-native-image

See also Gradle plugin for GraalVM Native Image building: https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html

CodePudding user response:

Seems like the right way to do it is though build.gradle file like below:

graalvmNative {
    binaries {
        main {
            buildArgs "-H:IncludeResources=\"com/amazonaws/partitions/endpoints.json\""
        }
    }
}
  •  Tags:  
  • Related