Skip to content

Conversation

@vaano94
Copy link

@vaano94 vaano94 commented Nov 22, 2025

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:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (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.

maven.build.cache.enable=false
and
maven.build.cache.skipCache=true
to avoid build failure

Co-authored-by: Yury Yerokhin <yury.yerokhin@gmail.com>
@sebtiem
Copy link
Contributor

sebtiem commented Nov 23, 2025

created during hack.commit.push event

@vaano94
Copy link
Author

vaano94 commented Nov 25, 2025

hmm, would it be possible to restart the 4.x builds? The single failed one lists this as an error:

Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.apache.maven:maven-core:pom:4.0.0-alpha-8 from/to central (https://repo.maven.apache.org/maven2): HTTP connect timed out

Copy link

Copilot AI left a 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.java to only call findCachedBuild() when cache is initialized, removing the || skipCache condition that was causing unwanted lookups
  • Added comprehensive integration tests to verify all four combinations of the enabled and skipCache parameters

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 {
Copy link

Copilot AI Dec 1, 2025

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.

Suggested change
void enabledCacheAndSkippingCacheShouldNotCreateCache(Verifier verifier) throws VerificationException {
void enabledCacheAndSkippingCacheShouldCreateButNotReadCache(Verifier verifier) throws VerificationException {

Copilot uses AI. Check for mistakes.
Copy link
Author

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
Copy link

Copilot AI Dec 1, 2025

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).

Suggested change
// 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

Copilot uses AI. Check for mistakes.
Copy link
Author

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

Co-authored-by: Erik Meuwese <Erik.Meuwese@topicus.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants