Skip to content

Experiment: migrate to Maven 4 BuildContext API - #496

Draft
gnodet wants to merge 4 commits into
masterfrom
experiment/maven4-build-context
Draft

Experiment: migrate to Maven 4 BuildContext API#496
gnodet wants to merge 4 commits into
masterfrom
experiment/maven4-build-context

Conversation

@gnodet

@gnodet gnodet commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Experimental branch migrating maven-resources-plugin to use the new Maven 4 BuildContext API (from apache/maven#12576) via the updated maven-filtering library (apache/maven-filtering#363).

  • Inject BuildContext into ResourcesMojo to support incremental resource processing
  • Simplify mojo logic: delegate incremental file selection to maven-filtering's BuildContext-aware processing, removing duplicated include/exclude logic
  • Use markSkipExecution() when execution is skipped (e.g., skip=true)
  • Fix test DI: provide BuildContext and PathMatcherFactory via @Provides @Priority(10) in each test class to avoid MojoExecutionScoped resolution failure
  • All 24 tests pass

Depends on

Test plan

  • All 24 maven-resources-plugin tests pass
  • Integration test with a real Maven build

🤖 Generated with Claude Code

gnodet and others added 4 commits July 29, 2026 13:46
…cessing

Inject the new Maven 4 BuildContext (org.apache.maven.api.build.context)
into ResourcesMojo and use it for incremental change detection:

- Register all resource files as inputs via buildContext.registerInputs()
- Check Metadata<Input>.getStatus() for NEW/MODIFIED status
- Skip resource processing entirely when no changes detected
- Call buildContext.markSkipExecution() to carry over state

Also update to maven-filtering 4.0.0-beta-2-SNAPSHOT which has been
migrated to use the new BuildContext API directly, removing the need
for the old plexus-build-api dependency.

Depends on: apache/maven#12576 (BuildContext API in maven-api-core)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…iltering

Remove registerResourceInputs() from the mojo — BuildContext interaction
now lives entirely in maven-filtering's DefaultMavenResourcesFiltering.
This eliminates double-registration and keeps a single registration
point for all plugins that use maven-filtering.

The mojo now only:
- Resolves resource roots
- Calls doExecute() which delegates to maven-filtering
- Uses markSkipExecution() for explicit skip scenarios

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Provide BuildContext and PathMatcherFactory via @provides @priority(10)
methods in each test class so the test DI container can resolve
DefaultMavenResourcesFiltering without requiring the MojoExecutionScoped
infrastructure from the full Maven runtime.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Delete the empty Providers.java (was the old plexus BuildContext
provider, now unused) and remove the stale comment from pom.xml.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant