Fix #375: Capture plugin properties at validation time to eliminate timing mismatch #395
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.
Problem
Maven 4 automatically injects
--module-version ${project.version}into compiler arguments during execution, but the build cache validates properties before execution. This creates a timing mismatch that causes cache invalidation:Root Cause Analysis
The cache extension currently reads plugin properties at different lifecycle points for different builds:
The problem: validation reads BEFORE injection, storage reads AFTER injection.
Solution
Capture properties at validation time for ALL builds (even when no cache exists). Store ONLY validation-time values in the cache. This ensures both validation and storage read at the same lifecycle point.
Implementation
CacheResultto store validation-time mojo eventsBuildCacheMojosExecutionStrategyto capture properties immediately afterfindCachedBuild()save()to store ONLY validation-time events (fails withAssertionErrorif missing)Key Code Changes
Note: Execution-time values are still captured by
MojoParametersListenerfor logging/debugging during the build, but are NOT stored in the cache.New Timeline (Both Builds)
What Gets Stored vs. Logged
This approach ensures cache consistency while preserving debugging information in build logs.
Benefits Over PR #391
ignorePattern)Testing
Created comprehensive integration tests:
--module-versionmoduleVersionconfigurationAll tests verify:
ignorePatternconfiguration requiredBackward Compatibility
ignorePatternstill works but is no longer necessary for Maven 4 injectionAlternative Approaches Considered
Related Issues
Migration
No migration needed. This change is transparent to users. Existing projects will benefit automatically.