Add incremental build context API and implementation - #12576
Conversation
e5a76c1 to
1e02718
Compare
|
Plexus Build API also provides context aware (file, line) logging. Would be good to add here as well Update: Seems this is part of resource now and therefore already considered. |
Just one note from experience with https://github.com/codehaus-plexus/plexus-build-api:
|
|
Thanks @kwin and @laeubi for the feedback. I spent time going through the plexus-build-api rework and the referenced issues — very useful context. On naming / separation of concerns (@laeubi point 1) Agreed that the old plexus-build-api That said, the diagnostic message part ( On the name itself: On IDE delta detection (@laeubi point 2) Fully agree — the implementation doesn't rely on IDE-driven deltas for correctness. Good point about On messages (@laeubi point 3, @kwin) As noted above, the context-aware message API ( |
1ac5eb0 to
dfd8d5c
Compare
Port and modernize the incremental build context from PR #1118, building on the original Sonatype plexus-build-api / Takari incrementalbuild work. API (maven-api-core): - BuildContext: register inputs, check status, associate outputs, skip execution, automatic stale output cleanup - SPI: Workspace (NORMAL/ESCALATED/SUPPRESSED), CommittableBuildContext, BuildContextEnvironment, BuildContextFinalizer - Diagnostic messages are NOT part of this API — use DiagnosticReporter from the build report API instead Implementation (maven-impl): - DefaultBuildContext with timestamp/size change detection - State serialization for cross-build persistence - PathMatcherFactory integration for Ant-style patterns - 36 tests Maven integration (maven-core): - MojoExecutionScoped DI wiring - ClasspathDigester + MojoConfigurationDigester for automatic configuration change detection - MavenBuildContextFinalizer for post-mojo commit - maven.buildcontext.skip property to disable entirely - Performance: released-artifact digest bypass, no-op state skip, single-syscall file status, field reflection cache Based on #12572 (Build Report Foundation). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dfd8d5c to
7d3165e
Compare
Summary
Port and modernize the incremental build context from PR #1118, building on the original Sonatype
plexus-build-api/ Takariincrementalbuildwork. This gives mojo authors a first-class API for incremental builds — tracking which input files changed, managing input→output associations, skipping unnecessary work, and cleaning up stale outputs automatically.Stacked on top of #12572 (Build Report Foundation). Diagnostic messages are handled by
DiagnosticReporterfrom #12572, not by this API — clean separation of concerns per @laeubi's feedback.Companion PRs demonstrate the API with four core plugins:
Closes #1118.
What's in this PR
Public API (
maven-api-core) — 14 types in 2 packagesorg.apache.maven.api.build.context— mojo-facing API:BuildContextInput/OutputInputSetMetadata<R>ResourceStatusNEW,MODIFIED,UNMODIFIED,REMOVED@IncrementalBuildContextExceptionMavenException)org.apache.maven.api.build.context.spi— integration SPI:WorkspaceCommittableBuildContextcommit()for state persistenceBuildContextEnvironmentBuildContextFinalizerFileStateNot in this API (handled by #12572): diagnostic messages, severity levels, message sinks. Mojos should use
DiagnosticReporterfor structured diagnostics.Implementation (
maven-impl) — 12 classes + 8 test classes (36 tests)Core incremental build engine in
o.a.m.internal.build.context.impl.Maven integration (
maven-core) — 5 classesDI wiring, configuration digesting, post-mojo commit finalization,
maven.buildcontext.skipproperty.Performance
Benchmarked against stock 3.x plugins on a 20-module reactor (4000 sources, 600 resources):
-Dmaven.buildcontext.skip=truedisables the context entirely for CI/release builds.Key design decisions
No diagnostic messages in this API —
DiagnosticReporterfrom Build report, console modes, and warning control #12572 handles diagnostics. A future bridge PR will replay previous-build diagnostics for unchanged files so warning counts stay consistent across incremental builds.No DELTA workspace mode — per @laeubi's feedback from plexus-build-api experience, IDE-driven delta detection is unreliable. Maven does its own timestamp scan (NORMAL mode). IDE integration focuses on output notification (
newOutputStream), not input detection.Automatic config change detection — digests all
@Parameterfields and plugin classpath. Mojos get this for free.maven.buildcontext.skip— disables digesting, state persistence, and tracking entirely. Zero overhead for CI clean builds.Test plan
maven-implMavenITgh12576IncrementalBuildContextTest🤖 Generated with Claude Code