Experiment: migrate to Maven 4 BuildContext API - #363
Draft
gnodet wants to merge 5 commits into
Draft
Conversation
Replace the old Scanner-based plexus BuildContext with the new Maven 4 BuildContext API (org.apache.maven.api.build.context.BuildContext) from maven-api-core 4.1.0-SNAPSHOT (PR apache/maven#12576). Key changes: - DefaultMavenResourcesFiltering: replace buildContext.newScanner() and newDeleteScanner() with buildContext.registerAndProcessInputs() which returns Input objects with change status tracking - DefaultMavenFileFilter: remove buildContext.refresh() — output tracking is now handled by the BuildContext output association in the mojo - Remove plexus-build-api dependency from pom.xml - Delete old TestIncrementalBuildContext and IncrementalResourceFilteringTest (these tested the old Scanner-based API) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add proper per-file incremental processing using Maven 4 BuildContext: - registerAndProcessInputs() for all resource files - Separate changed (NEW/MODIFIED) from unchanged (UNMODIFIED) inputs - Only copy/filter changed files in incremental mode - input.associateOutput() for stale output cleanup on file removal - Informative logging: "Copying N of M resources (Z unchanged)" - @nullable BuildContext for backward compat (tests without DI) - Ant-style pattern matching fallback using PathMatcher with proper escaping of glob metacharacters ({, }, [, ]) and leading **/ zero-directory matching Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…sion
Replace custom Ant-to-glob pattern conversion (escapeGlobMetachars,
toPathMatchers, matchesAny) with Maven 4's PathMatcherFactory service.
PathSelector already handles all the nuances:
- Escaping {, }, [, ] as literals
- Leading **/ matching zero directories
- **/** normalization
- Comprehensive default SCM excludes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add IncrementalResourceFilteringTest (9 tests) exercising the Maven 4 BuildContext incremental code path: initial build, no-change skip, modified input re-processing, stale output cleanup, include/exclude patterns, new file detection, filtering, and subdirectory structure. - Fix path normalization: normalize resourceDirectory to absolute path after existence check so relativize() works correctly with BuildContext's canonicalized paths. - Fix flatten + associateOutput: skip associateOutput() when flattening since multiple inputs can map to the same output, violating the BuildContext's one-input-to-one-output constraint. - Update Providers.java: provide real BuildContext and PathMatcherFactory for test DI with @priority(10) to override auto-discovered MavenBuildContext from maven-core. - Remove stale plexusBuildApiVersion property from pom.xml. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 tasks
The dependency was already removed; this just cleans up the leftover comment marker. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Experimental branch migrating maven-filtering from the legacy plexus-build-api to the new Maven 4
BuildContextAPI (from apache/maven#12576).org.apache.maven.api.build.context.BuildContextfrommaven-api-coreregisterAndProcessInputs()to only process changed/new files and clean up stale outputs automaticallyassociateOutput()when flattening (multiple inputs → same output)IncrementalResourceFilteringTest) exercising: initial build, no-change skip, modified input, deleted input cleanup, include/exclude patterns, new file detection, filtering, and subdirectory structureDepends on
Test plan
🤖 Generated with Claude Code