Reputation: 23
I am using Spring Boot 3.3.5 and would like to build a native image with a specific set of profiles and set some build arguments to enable some third party libraries to compile. My project uses spring-boot-starter-parent as the parent POM. Is there a way to either override the Spring defined plugins or pass parameters to the native Maven profile when running this?
mvn -Pnative native:compile
Currently I copy and pasted the entire Spring native profile and modified a few parameters and would like to ask the community here if there is a more maintainable solution that doesn't involve redefining parts of Spring parent pom?
Additional Details:
Paketo build packs not used as Docker isn't available on my CI servers
Native image compiled with 2 profiles baked into the image
We have a few libraries that causes build failures unless they are initialized at build time with initialize-at-build-time
Snippet below contains 2 native profile sections that I modified to build
My project contains existing spring-boot-maven-plugin with different settings needed when running in JVM mode and the solution shouldn't interfere with JVM/native modes
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<builder>paketobuildpacks/builder-jammy-tiny:latest</builder>
<env>
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
</env>
</image>
<profiles ****>profile1,profile2</profiles>
</configuration>
<executions>
<execution>
<id>process-aot</id>
<goals>
<goal>process-aot</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
<requiredVersion>22.3</requiredVersion>
<buildArgs ****>
--initialize-at-build-time=de.schlichtherle.truezip.nio.charset.ZipCharsetProvider
-R:MaxHeapSize=50m
</buildArgs>
</configuration>
<executions>
<execution>
<id>add-reachability-metadata</id>
<goals>
<goal>add-reachability-metadata</goal>
</goals>
</execution>
</executions>
</plugin>
Upvotes: 0
Views: 68