spring-attic / spring-native

Spring Native is now superseded by Spring Boot 3 official native support
https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html
Apache License 2.0
2.74k stars 355 forks source link

Maven multi module : merge json config files of the tracing agent #1685

Closed mpumd closed 2 years ago

mpumd commented 2 years ago

Hi everyone, I hope you're very well.

I come back to you about a problematic on the tracing agent piloted by the surefire maven plugin.

Context : In maven multimodule project, I need to merge all config json files from the tracing agent into the bootstrap module; where maven build the uber jar. The tracing agent has a capacity to merge with config-merge-dir parameter. So I use it to redirect the output inside the target of the bootstrap module.

My approch is to split on two maven life cycles.

// usefull to force the target clean on all multi module project 
// and avoid clean the target of the bootstrap module anytime during a lifecycle. 
mvn clean 

// run the tracing agent and merge the files inside the target of the bootstrap module
mvn test -PtracingAgentOld  

What do you think ? I guess you have already encountered this problem. Do you have a better idea ?

Thanks !

sdeleuze commented 2 years ago

Hi, I am not sure to understand what is exactly the problem you want to solve since config-merge-dir seems to be a valid way to do this. Could you please elaborate?

mpumd commented 2 years ago

Hi Mister Deleuze,

Sorry for late.

My point is about the merge of json files of the tracing agent in a multimodule maven project environnement. You're solve this problem in the AOT plugin. If I understood correctly, the plugin produce a graalvm json files inside every maven module. Next, the AOT plugin (or other) merge all json files into the bootstrap maven module, where you have a spring-boot maven plugin configured.

How did you do merge json configs with the AOT plugin ?

When you run a maven lifecyle, maven can clean a target anytime. If you configure the config-merge-dir in the target of the boostrap maven module, you risk losing your json files.

I hope it's clear. I'm sorry if the question is a bit off topic compared to spring native. Thanks for your time.

Have a great day and best weekend !

sdeleuze commented 2 years ago

We don't need to merge those file, GraalVM native-image will automatically merge all the files detected in the various META-INF/native-image directories available in the various modules. Usually a best practice is to use META-INF/native-image/groupId/artifactId with groupId and artifactId to be replaced with values accurate for your modules. See more documentation in https://www.graalvm.org/22.2/reference-manual/native-image/metadata/.

mpumd commented 2 years ago

Good to know. Thanks for your answer.

Best regards.