- Notifications
You must be signed in to change notification settings - Fork 55
Description
Affected version
1.2.0
Bug description
Environment
- Maven: 4.0.0-rc-4
- Java: 24
- Maven Compiler Plugin: 3.14.0
- Project Type: Multi-module project with module-info.java files
Expected Behavior
Subsequent mvn verify runs
should use cached compilation results when no source code has changed.
Actual Behavior
Every mvn verify
run forces full project rebuilds with these error messages:
[INFO] Plugin parameter mismatch found. Parameter: compilerArgs, expected: [-Xlint:all,-module,-requires-automatic,-requires-transitive-automatic,-missing-explicit-ctor, -Xdiags:verbose, -Werror, --module-version, 1.0-SNAPSHOT], actual:
[-Xlint:all,-module,-requires-automatic,-requires-transitive-automatic,-missing-explicit-ctor, -Xdiags:verbose, -Werror]
[INFO] Mojo cached parameters mismatch with actual, forcing full project build. Mojo: compiler:compile
[INFO] A cached mojo is not consistent, continuing with non cached build
Root Cause Analysis
The Maven Build Cache Extension has inconsistent behavior when tracking compiler arguments for Java modules:
- During Cache Storage: Records
--module-version ${project.version}
as an expected parameter - During Cache Validation: The actual runtime parameters don't include
--module-version
- Result: Parameter mismatch causes cache invalidation
Technical Details
Maven Compiler Plugin Configuration
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.14.0</version> <configuration> <fork>true</fork> <meminitial>512m</meminitial> <maxmem>2048m</maxmem> <useIncrementalCompilation>true</useIncrementalCompilation> <compilerArgs> <arg>-Xlint:all,-module,-requires-automatic,-requires-transitive-automatic,-missing-explicit-ctor</arg> <arg>-Xdiags:verbose</arg> <arg>-Werror</arg> </compilerArgs> </configuration> </plugin>
Module Structure
Project contains module-info.java files in multiple modules:
- server/src/main/java/module-info.java
- tax/src/main/java/module-info.java
- simulator/src/main/java/module-info.java
Attempted Workarounds
All of the following configurations still exhibit the same issue:
- Empty moduleVersion:
- Null moduleVersion:
- Explicit moduleVersion: ${project.version}
- Explicit compilerArgs: Adding --module-version manually to compilerArgs (causes duplicate parameters)
Reproduction Steps
- Create a multi-module Maven project with module-info.java files
- Configure Maven Compiler Plugin with compilerArgs
- Enable Maven Build Cache Extension
- Run
mvn clean verify
(builds successfully, creates cache) - Run
mvn verify
again (should use cache but forces full rebuild instead)
Impact
- Build Performance: 3-5x slower builds due to cache misses
- Development Workflow: Affects incremental build efficiency
- CI/CD: Increased build times in continuous integration
Expected Fix
Maven Build Cache Extension should consistently track module versioning parameters between cache storage and validation phases, either:
- Always include
--module-version
in both expected and actual parameters, or - Never include
--module-version
in either set when not explicitly configured
Workaround
Currently, no effective workaround exists. The issue persists regardless of moduleVersion configuration attempts.