-
Notifications
You must be signed in to change notification settings - Fork 59
#218 Do not lookup for existing cache with given skip cache and cache enabled parameters #413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
#218 Do not lookup for existing cache with given skip cache and cache enabled parameters #413
Conversation
maven.build.cache.enable=false and maven.build.cache.skipCache=true to avoid build failure Co-authored-by: Yury Yerokhin <yury.yerokhin@gmail.com>
|
created during hack.commit.push event |
|
hmm, would it be possible to restart the 4.x builds? The single failed one lists this as an error:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses issue #218 by fixing the cache lookup behavior when the cache is disabled. Previously, the code would attempt to look up cached builds even when maven.build.cache.enabled=false combined with maven.build.cache.skipCache=true, which could cause build failures. The fix ensures that cache lookups only occur when the cache is properly initialized.
Key Changes:
- Modified the condition in
BuildCacheMojosExecutionStrategy.javato only callfindCachedBuild()when cache is initialized, removing the|| skipCachecondition that was causing unwanted lookups - Added comprehensive integration tests to verify all four combinations of the
enabledandskipCacheparameters
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/org/apache/maven/buildcache/BuildCacheMojosExecutionStrategy.java | Removed || skipCache condition to prevent cache lookups when cache is not initialized |
| src/test/java/org/apache/maven/buildcache/its/SkipCacheParamTest.java | Added integration test class with 4 test methods covering all parameter combinations |
| src/test/projects/skip-cache-param/src/main/java/Main.java | Simple test project main class for integration testing |
| src/test/projects/skip-cache-param/pom.xml | Maven POM configuration for the test project |
| src/test/projects/skip-cache-param/.mvn/extensions.xml | Maven extension configuration to enable the build cache extension for testing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| @Test | ||
| void enabledCacheAndSkippingCacheShouldNotCreateCache(Verifier verifier) throws VerificationException { |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test method name and comment contradict each other. The method is named enabledCacheAndSkippingCacheShouldNotCreateCache but the comment on line 78 states "cache should not be read, only be created" and the test verifies on line 87 that the cache is saved. The method name should reflect that cache IS created but not read/restored.
| void enabledCacheAndSkippingCacheShouldNotCreateCache(Verifier verifier) throws VerificationException { | |
| void enabledCacheAndSkippingCacheShouldCreateButNotReadCache(Verifier verifier) throws VerificationException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly find existing test name quite good since it does address the current issue: cache is being created when it's not the desired result
|
|
||
| @Test | ||
| void enabledCacheAndSkippingCacheShouldNotCreateCache(Verifier verifier) throws VerificationException { | ||
| // cache.enabled=true , cache.skipCache= true => cache should not be read, only be created |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment has a grammatical issue with inconsistent spacing: "cache.skipCache= true" should be "cache.skipCache=true" (missing space before equals sign, or add space after it for consistency).
| // cache.enabled=true , cache.skipCache= true => cache should not be read, only be created | |
| // cache.enabled=true , cache.skipCache=true => cache should not be read, only be created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how important is this? I would ignore such suggestion this as well
| public class Main | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public class Main | |
| { | |
| public class Main { |
code formatting: { should be on the same line
Do not lookup for existing cache with maven.build.cache.enable=false and maven.build.cache.skipCache=true to avoid build failure. Add additional integration tests to prove parameter combinations.
Following this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verifyto make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
mvn -Prun-its verify).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.