Skip to content

experiment: leverage BuildContext API for skip-execution signaling - #1096

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

experiment: leverage BuildContext API for skip-execution signaling#1096
gnodet wants to merge 2 commits into
masterfrom
experiment/maven4-build-context

Conversation

@gnodet

@gnodet gnodet commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Integrate the Maven 4 BuildContext API into the compiler plugin to signal markSkipExecution() when compilation is skipped
  • Covers three skip paths: CompilerMojo (when skipMain is true), TestCompilerMojo (when skip is true), and AbstractCompilerMojo (when applyIncrementalBuild() returns false)
  • Enables downstream mojos (e.g., jar plugin) to detect that the compiler was skipped and react accordingly

Details

This is an experimental branch that depends on:

Changes

  • AbstractCompilerMojo.java: Added @Inject BuildContext buildContext field, signals markSkipExecution() when applyIncrementalBuild() returns false (nothing to compile)
  • CompilerMojo.java: Added markSkipExecution() when skipMain is true
  • TestCompilerMojo.java: Added markSkipExecution() when skip is true
  • CompilerMojoTestCase.java: Updated test imports to new org.apache.maven.testing.plugin package, added @Provides methods for BuildContext and PathMatcherFactory
  • pom.xml: Bumped mavenVersion to 4.1.0-SNAPSHOT

Test plan

  • All existing tests pass (16/16)
  • Integration testing with a multi-module project to verify skip signaling

🤖 Generated with Claude Code

gnodet and others added 2 commits July 29, 2026 16:17
Integrate the Maven 4 BuildContext API into the compiler plugin to
signal markSkipExecution() when compilation is skipped. This covers:
- CompilerMojo: when skipMain is true
- TestCompilerMojo: when skip is true
- AbstractCompilerMojo: when applyIncrementalBuild() returns false

This enables downstream mojos to detect that the compiler was skipped
and react accordingly (e.g., skip JAR creation).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the compiler plugin's custom IncrementalBuild change-detection
engine with the Maven 4 BuildContext API for source tracking, change
detection, stale output cleanup, and state persistence.

Key changes:
- ToolExecutor.applyIncrementalBuild() now registers source files via
  BuildContext.registerInput() and checks Status (NEW/MODIFIED/UNMODIFIED)
  instead of the old timestamp-based IncrementalBuild logic
- OPTIONS aspect delegates to BuildContext's MojoConfigurationDigester
  (automatic parameter digestion replaces manual options hashing)
- DEPENDENCIES aspect registers dependency JARs as BuildContext inputs
  (content-based SHA-1 hashing replaces timestamp comparison)
- After compilation, associateOutputs() discovers class files including
  inner classes (Foo$Bar.class, Foo$1.class) and calls
  Input.associateOutput() for each, enabling automatic stale output
  cleanup when sources are removed
- IncrementalBuild class reduced to Aspect enum and isEmptyOrIgnorable()
  utility — all instance state, cache I/O, and change detection logic
  removed
- meta.process() calls deferred until after isEmptyOrIgnorable() check
  to avoid IllegalStateException when markSkipExecution() is called
- Test updated to reinitialize BuildContext between executions (matching
  Maven DI behavior where each execution gets a fresh context)

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