gnodet opened a new pull request, #13983: URL: https://github.com/apache/maven/pull/13983
> **Stacked on top of #XXXX** (Build Report Foundation). Merge that one first. ## Summary Port and modernize the incremental build context from PR #1118, building on the original Sonatype `plexus-build-api` / Takari `incrementalbuild` work. 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. Diagnostic messages are handled by `DiagnosticReporter`, not by this API — clean separation of concerns per @laeubi's feedback. Companion PRs demonstrate the API with four core plugins: - **maven-filtering** — [apache/maven-filtering#363](https://github.com/apache/maven-filtering/pull/363) - **maven-resources-plugin** — [apache/maven-resources-plugin#496](https://github.com/apache/maven-resources-plugin/pull/496) - **maven-jar-plugin** — [apache/maven-jar-plugin#566](https://github.com/apache/maven-jar-plugin/pull/566) - **maven-compiler-plugin** — [apache/maven-compiler-plugin#1096](https://github.com/apache/maven-compiler-plugin/pull/1096) Closes #1118. ## What's in this PR ### Public API (`maven-api-core`) — types in `org.apache.maven.api.build.incremental` | Type | Role | |------|------| | `IncrementalContext` | Main entry point — register inputs/outputs, check status, associate files | | `Input` / `Output` | Tracked input and output resources with status | | `InputSet` | Aggregation support (many inputs → one output, e.g., JAR, index) | | `Metadata<R>` | Lazy status inspection before committing to process | | `Resource` | Base for Input/Output — path, status | | `Status` | Change status enum: `NEW`, `MODIFIED`, `UNMODIFIED`, `REMOVED` | | `@Incremental` | Annotation for mojo fields — marks config parameters for change detection | | `IncrementalContextException` | Runtime exception (extends `MavenException`) | **SPI** (`spi` subpackage): | Type | Role | |------|------| | `Workspace` | Filesystem abstraction with 3 modes (NORMAL, ESCALATED, SUPPRESSED) | | `CommittableIncrementalContext` | Extended context with `commit()` for state persistence | | `IncrementalContextEnvironment` | Construction parameters (state file, workspace, config, finalizer) | | `IncrementalContextFinalizer` | Batch-commits all contexts after mojo success | | `FileState` | Immutable value object for file metadata | ### Implementation (`maven-impl`) — core incremental build engine + tests ### Maven integration (`maven-core`) — DI wiring, configuration digesting, post-mojo commit finalization, `maven.incrementalbuild.skip` property ## Key design decisions 1. **No diagnostic messages in this API** — `DiagnosticReporter` handles diagnostics. A future bridge PR will replay previous-build diagnostics for unchanged files so warning counts stay consistent across incremental builds. 2. **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). 3. **Automatic config change detection** — digests all `@Parameter` fields and plugin classpath. Mojos get this for free. 4. **`maven.incrementalbuild.skip`** — disables digesting, state persistence, and tracking entirely. Zero overhead for CI clean builds. ## Test plan - [x] Unit tests in `maven-impl` - [x] Integration test: `MavenITgh12576IncrementalContextTest` - [ ] CI build passes -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
