apache / apache/maven-build-cache-extension

The change in the mvn -P parameter does not invalidate the cache

Open
#414 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
163
Forks
77
Avg merge
1d 2h
Merged PRs (30d)
4

Description

### Affected version

1.2.1

### Bug description

After executing the command `mvn clean package -Dmaven.test.skip=true -Pdev -f ./pom.xml`, and then modifying the -P parameter to execute `mvn clean package -Dmaven.test.skip=true -Ptest -f ./pom.xml`, the build retrieved an incorrect cache.
pom.xml
```



org.springframework.boot
spring-boot-maven-plugin

true
ServerApplication




repackage




org.apache.maven.plugins
maven-compiler-plugin

8
8





src/main/resources

spring-service-dubbo.xml



src/main/resources/${profiles.active}



```
I tried to modify the maven-build-cache-config.xml by adding the following configuration:
```








```
Rebuilding the cache is not working anymore.
```
[INFO] Scanning plugins configurations to find input files. Probing is enabled, values will be checked for presence in file system
[INFO] Found 135 input files. Project dir processing: 12, plugins: 1 millis
...
[INFO] Project inputs calculated in 24 ms. SHA-256 checksum [179be61b922f372ba9a918eb809217a535ff3d9b31c09236bb0a0bee395f38ae] calculated in 163 ms.
[INFO] Attempting to restore project ... from build cache
[INFO] Local build found by checksum 179be61b922f372ba9a918eb809217a535ff3d9b31c09236bb0a0bee395f38ae
[INFO] Found cached build, restoring ... from cache by checksum 179be61b922f372ba9a918eb809217a535ff3d9b31c09236bb0a0bee395f38ae
[WARNING] Tracked property `resources` not found in cached build. Execution: default-resources:resources:process-resources:maven-resources-plugin:org.apache.maven.plugins
[WARNING] Cached build record doesn't contain all tracked properties. Plugin: Plugin [org.apache.maven.plugins:maven-resources-plugin], goal: resources, executionId: default-resources
[INFO] Cached build violates cache rules, cannot restore
```
Is there a solution to address the issue of differentiating the -P parameter?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the two Maven commands from the report against the shown pom.xml, switching between the dev and test profiles. Read the maven-build-cache-config.xml reconciliation settings and compare the logged cache inputs and tracked properties. Done means profile changes produce distinct cache results without the reported cached-build validation warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.