slovelo
slovelo

Reputation: 23

Configure build arguments and profiles in Maven for Spring Boot GraalVM Native Image

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:

<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

Answers (0)

Related Questions