native-build-tools icon indicating copy to clipboard operation
native-build-tools copied to clipboard

Improve the documentation relating to using the tracing agent to generate reflection config from the unit tests

Open krisfoster opened this issue 3 years ago • 6 comments
trafficstars

I think the documentation for the maven tool needs to be expanded. It's not super clear what the process should be using the tracing agent when you have tests and when you build a native binary. Consider the following (assumes some project using maven that has tests, uses reflection etc and has a profile for the native build tools):

// Builds the tests natively and runs them - picks up the reflection config from target (-H:ConfigurationFileDirectories) // Note that the native unit testing explicitly passes in the location of the tracing agent config, see above mvn -Pnative -Dagent=true test

// Builds the native binary, BUT it doesn’t reference the reflection config. The binary fails at runtime mvn -Pnative -Dagent=true package

What one needs to do is to copy over the reflection config generated by the tracing agent when running the tests. Without this, this leads to the binary failing at runtime.

Think we should have an example of working through this. Can fully understand that we don't necessarily want to copy over the tracing config, but the fact that the tests work with no change but the binary fails is confusing for the the end user.

Thanks!

krisfoster avatar Sep 14 '22 14:09 krisfoster

@sdeleuze, is this similar to an issue you once raised?

sbrannen avatar Sep 19 '22 14:09 sbrannen

Yes I think. There is a pretty complete documentation on https://github.com/oracle/graalvm-reachability-metadata/blob/master/docs/CollectingMetadata.md but it is on reachability metadata side and it is currently Gradle only.

@gradinac Maybe we could document this properly on NBT Gradle and Maven documentation and just point reachability metadata to the related sections of NBT documentation.

sdeleuze avatar Sep 23 '22 09:09 sdeleuze

Potentially depends on #260.

sdeleuze avatar Sep 23 '22 09:09 sdeleuze

  • So, the documentation should provide a link to https://www.graalvm.org/dev/reference-manual/native-image/guides/use-native-image-maven-plugin/ ? But from a novice point of view, the pom.xml of https://github.com/graalvm/graalvm-demos/tree/master/fortune-demo is really quite complicated.

linghengqian avatar Sep 28 '22 12:09 linghengqian

  • Considering https://github.com/graalvm/native-build-tools/pull/343 , if the maven plugin has the same experience with the agent mode as the gradle plugin, shouldn't this issue be considered resolved? Because there is a metadataCopy task.

linghengqian avatar Feb 13 '23 19:02 linghengqian

Potentially yes.

@dnestoro Could you please check and close this issue if confirmed?

sdeleuze avatar Feb 16 '23 15:02 sdeleuze