Add AOT cache recording to build plugins and bootBuildImage - #51101
Closed
vpelikh wants to merge 1 commit into
Closed
Add AOT cache recording to build plugins and bootBuildImage#51101vpelikh wants to merge 1 commit into
vpelikh wants to merge 1 commit into
Conversation
Integrate Leyden AOT cache recording into the build plugin lifecycle. aotCacheRecord=true is the single user-facing property that handles both recording from tests and bundling the cache into the image. Maven: - AotCacheRecordMojo at INITIALIZE phase reads spring-boot.aot-cache-record property and injects -XX:AOTCacheOutput into surefire argLine - Only activates when spring-boot:build-image is in the execution plan (checks MavenSession.getGoals()) - Image.customize() bundles target/aot-cache into the image when present - BuildImageMojo wires cacheDirectory from project.build.directory Gradle: - BootBuildImage exposes aotCacheRecord Property<Boolean> - JavaPluginAction configures test JVM args in afterEvaluate, guarded by task graph check (graph.hasTask for bootBuildImage) - customizeAotCache() sets BP_JVM_AOTCACHE_ENABLED and bundles the cache directory when aotCacheRecord=true Buildpack: - BuildRequest.withAdditionalContent(Path, String) merges a filesystem directory into the application archive - CompositeTarArchive combines primary archive with additional content Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
Member
|
@vpelikh thanks for the PR but it isn't actionable right now. I'd like to make sure we reach a conclusion in the related Spring framework issue and we can then consider a contribution. |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Integrates Leyden AOT cache (JEP 483) recording into the Spring Boot Maven and Gradle build plugins, configured declaratively with a single switch. When enabled, the build records an AOT cache from the integration tests and bundles it into the OCI image, so the application reuses the pre-recorded cache at container startup.
Configuration
Maven — bind the
aot-cache-recordgoal to theinitializephase and set thespring-boot.aot-cache-recordproperty, then run tests together with the image build:mvn test spring-boot:build-imageGradle — set
aotCacheRecord = trueon thebootBuildImagetask and run tests together with the image build:bootBuildImage { aotCacheRecord = true }./gradlew test bootBuildImageWhat it does
Recording the cache from integration tests
When enabled, the plugin injects
-XX:AOTCacheOutput=<path>into the test JVM arguments, so the JVM records an AOT cache during integration test execution. Recording is gated on the image build being scheduled in the same execution:JavaPluginActioninjects the flag into the test JVM args viawhenReady, only when the project'sbootBuildImageis in the task graph.AotCacheRecordMojo(initialized in theinitializephase) injects the flag into the SurefireargLine, only whenspring-boot:build-imageis in the execution plan.The test-only paths do not record a cache; the image build fails closed with actionable guidance when the cache is expected but missing.
Bundling the cache into the image
The generated
aot-cache/application.aotis bundled into the OCI image andBP_JVM_AOTCACHE_ENABLED=trueis set for the Paketo buildpack.AOT cache compatibility metadata
AOT caches are JDK-version- and platform-specific. The plugins now write
aot-cache/application.aot.metaalongside the cache, recording thejava.versionandos.archof the JVM that built the image. The Paketo buildpack compares this against the JRE baked into the image and fails the build on a mismatch, preventing an incompatible cache from being reused.Related