Search code examples
gradlegraalvmspring-native

How do I run the GraalVM native image tracing agent from a Spring Native Gradle project?


I have found information on how to run the GraalVM native image tracing agent from a Spring Native Maven project, but I can't find info on how to do it from a Gradle project.

See https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#_using_it_with_maven.

Any ideas on how to do it from a Gradle project?


Solution

  • The assisted configuration javaagent is orthogonal to the build tool, so one needs to specify the correct arguments to the jvm running the tests:

    Something like this which the docs you reference outline: -agentlib:native-image-agent=access-filter-file=access-filter.json,config-output-dir=target/classes/META-INF/native-image

    I think in Gradle you just configure the test task with it:

    test { 
      jvmArgs -agentlib:native-image-agent=access-filter-file=access-filter.json,config-output-dir=target/classes/META-INF/native-image
    }
    

    Here's Gradle docs on the test task: https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html