Add ignorePattern attribute to TrackedProperty for array filtering#390
Closed
cowwoc wants to merge 2 commits into
Closed
Add ignorePattern attribute to TrackedProperty for array filtering#390cowwoc wants to merge 2 commits into
cowwoc wants to merge 2 commits into
Conversation
## Problem Without executionControl configuration, the build cache does not track critical plugin properties that are often specified via command-line arguments (e.g., -Dmaven.compiler.release). This leads to incorrect cache reuse when these properties change between builds. In multi-module JPMS projects, this manifests as compilation failures or bytecode version mismatches: 1. Build with `-Dmaven.compiler.release=17` → cache stores Java 17 bytecode (major version 61) 2. Build with `-Dmaven.compiler.release=21` → cache incorrectly reuses Java 17 bytecode 3. Result: Bytecode remains major version 61 instead of expected 65 This is particularly problematic for module-info.class files which are sensitive to Java version. ## Solution Implemented default reconciliation configs for common plugins when executionControl is not specified: - **maven-compiler-plugin** (compile & testCompile goals): - Tracks `source`, `target`, and `release` properties - Ensures cache invalidation when Java version changes - **maven-install-plugin** (install goal): - Tracked to ensure local repository is updated when needed ## Testing Verified with multi-module JPMS test project: **Before (broken):** ``` mvn clean verify -Dmaven.compiler.release=17 # Caches Java 17 bytecode mvn clean verify -Dmaven.compiler.release=21 # Incorrectly reuses Java 17 bytecode javap -v module-info.class | grep "major version" # Shows 61 (wrong!) ``` **After (fixed):** ``` mvn clean verify -Dmaven.compiler.release=17 # Caches Java 17 bytecode mvn clean verify -Dmaven.compiler.release=21 # Detects change, recompiles javap -v module-info.class | grep "major version" # Shows 65 (correct!) ``` ## Impact - Users no longer need to manually configure executionControl for basic scenarios - Prevents silent bytecode version mismatches in JPMS projects - Backward compatible: explicit executionControl config still takes precedence
Fixes apache#375 - Maven 4 auto-injects --module-version to compilerArgs during cache storage but not during validation, causing parameter mismatches. Changes: - Add ignorePattern field to TrackedProperty in MDO model - Implement regex-based filtering in BuildCacheMojosExecutionStrategy - Filter arrays before comparison (both runtime and cached values) - Update default reconciliation configs to filter --module-version The ignorePattern attribute allows filtering specific array elements before comparison, solving the Maven 4 module-version problem while still detecting legitimate compilerArgs changes. Tested with multi-module JPMS project using Maven 4.0.0-rc-4.
Contributor
Author
|
This PR addresses #375 by filtering out Maven 4's auto-injected |
Contributor
Author
|
Closing to recreate from clean master branch (without unrelated default reconciliation configs). Replaced by #391 |
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.
Fixes #375
Problem
Maven 4 auto-injects
--module-version ${project.version}tocompilerArgsduring cache storage but not during validation, causing parameter mismatches and forcing rebuilds on every invocation for modules withmodule-info.java.Solution
Add
ignorePatternattribute toTrackedPropertythat filters array elements using regex before comparison.Changes
build-cache-config.mdo): AddignorePatternfield toTrackedPropertyBuildCacheMojosExecutionStrategy.java):filterAndStringifyArray()- filters runtime array values before stringificationfilterArrayString()- filters cached string representationsCacheConfigImpl.java): TrackcompilerArgswithignorePattern="--module-version"for bothcompileandtestCompilegoalsTesting
Tested with multi-module JPMS project using Maven 4.0.0-rc-4:
--module-versionpresentcompilerArgschanges still invalidate cacheRelated Issues