Fix #375: Capture plugin properties at validation time to eliminate timing mismatch#395
Open
cowwoc wants to merge 6 commits into
Open
Fix #375: Capture plugin properties at validation time to eliminate timing mismatch#395cowwoc wants to merge 6 commits into
cowwoc wants to merge 6 commits into
Conversation
57a76d8 to
d2c8071
Compare
elharo
requested changes
Oct 28, 2025
Contributor
elharo
left a comment
There was a problem hiding this comment.
need to run mvn spotless:apply
cowwoc
added a commit
to cowwoc/maven-build-cache-extension
that referenced
this pull request
Oct 29, 2025
- Upgrade spotless-maven-plugin from 2.44.5 to 3.0.0 - Upgrade palantir-java-format from 2.56.0 to 2.81.0 for Java 25 support - Run mvn spotless:apply to format code Addresses review feedback on PR apache#395.
Contributor
Author
|
@elharo Done. Try now. |
elharo
reviewed
Dec 1, 2025
cowwoc
added a commit
to cowwoc/maven-build-cache-extension
that referenced
this pull request
Dec 1, 2025
- Split run-on sentence in AssertionError message - Use HashMap import instead of fully qualified name - Move Mojo variable declaration into try block (nested try-finally) - Return defensive copy from getValidationTimeEvents() for encapsulation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
cowwoc
added a commit
to cowwoc/maven-build-cache-extension
that referenced
this pull request
Dec 1, 2025
- Split run-on sentence in AssertionError message - Use HashMap import instead of fully qualified name - Move Mojo variable declaration into try block (nested try-finally) - Return defensive copy from getValidationTimeEvents() for encapsulation
43445c6 to
fda621a
Compare
cowwoc
added a commit
to cowwoc/maven-build-cache-extension
that referenced
this pull request
Dec 1, 2025
- Split run-on sentence in AssertionError message - Use HashMap import instead of fully qualified name - Move Mojo variable declaration into try block (nested try-finally) - Make getValidationTimeEvents() package-private
fda621a to
6cf3a36
Compare
elharo
requested changes
Dec 1, 2025
cowwoc
added a commit
to cowwoc/maven-build-cache-extension
that referenced
this pull request
Dec 1, 2025
- Upgrade spotless-maven-plugin from 2.44.5 to 3.0.0 - Upgrade palantir-java-format from 2.56.0 to 2.81.0 for Java 25 support - Run mvn spotless:apply to format code Addresses review feedback on PR apache#395.
cowwoc
added a commit
to cowwoc/maven-build-cache-extension
that referenced
this pull request
Dec 1, 2025
- Split run-on sentence in AssertionError message - Use HashMap import instead of fully qualified name - Move Mojo variable declaration into try block (nested try-finally) - Make getValidationTimeEvents() package-private
6cf3a36 to
04b6246
Compare
Contributor
Author
|
@elharo I've pushed a commit that should fix the latest build failures. Try now. |
c4c7a6c to
86c7750
Compare
elharo
approved these changes
Dec 3, 2025
Contributor
Author
|
It looks like the latest build errors are not related to this PR. Can it be merged? Do you need to do something else to fix the build? |
Contributor
|
Absolutely nothing should be merged on a failing build. A failing build blocks everything. |
Contributor
Author
|
@elharo Agreed, but is anyone taking a look at the failing build? |
…nate timing mismatch Maven 4 automatically injects --module-version into compiler arguments during execution, but cache validation happens before execution. This creates a timing mismatch that causes cache invalidation. This fix captures properties at validation time for ALL builds and stores ONLY validation-time values in the cache, ensuring consistent reading at the same lifecycle point. Changes: - Modified CacheResult to store validation-time mojo events - Added captureValidationTimeProperties() to BuildCacheMojosExecutionStrategy - Modified execute() to capture properties after findCachedBuild() - Modified save() to store ONLY validation-time events (AssertionError if missing) - Added comprehensive integration tests (Maven4Jpms, ExplicitModuleVersion, NonJpms, MultiModule) Benefits: - No configuration required (vs ignorePattern in PR apache#391) - Fixes root cause (timing mismatch) not symptom (value mismatch) - Works for ALL Maven 4 auto-injected properties - Preserves execution-time logging for debugging Alternative to PR apache#391
- Upgrade spotless-maven-plugin from 2.44.5 to 3.0.0 - Upgrade palantir-java-format from 2.56.0 to 2.81.0 for Java 25 support - Run mvn spotless:apply to format code Addresses review feedback on PR apache#395.
- Split run-on sentence in AssertionError message - Use HashMap import instead of fully qualified name - Move Mojo variable declaration into try block (nested try-finally) - Make getValidationTimeEvents() package-private
- Fix invalid XML in pom.xml comment (-- not allowed in XML comments) - Fix cache config XML validation errors by simplifying config - Change tests to use 'package' goal instead of 'compile' since cache extension stores artifacts, not intermediate output directories - Fix AssertionError when running clean-only builds by gracefully skipping cache storage when no cacheable mojos executed
Put LOGGER.debug() call on single line to satisfy Spotless formatting rules.
Add missing Apache Software Foundation license headers to all test project files as required by Apache conventions: - explicit-module-version: pom.xml, extensions.xml, module-info.java, ExplicitVersionModule.java - maven4-jpms-module: pom.xml, extensions.xml, module-info.java, HelloMaven4.java - multi-module-jpms: parent and module pom.xml files, extensions.xml, module-info.java, ModuleA.java, ModuleB.java - non-jpms-project: pom.xml, extensions.xml, RegularJavaClass.java maven-build-cache-config.xml files already had correct license headers.
230fc07 to
256c64f
Compare
Contributor
Author
Contributor
Author
|
This PR is approved but unmerged. Can someone please merge it? |
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.
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.