Skip to content

Conversation

atsteffen
Copy link
Contributor

@atsteffen atsteffen commented Feb 16, 2023

Use-case:
You may have cases where you want to setup a remote cache, but for whatever reason developers or some build machines do not have access to the server, or have slow internet connection that makes downloading artifacts not sufficiently advantageous over building and caching locally only.

With this parameter, the remote cache can be disabled by default and selectively enabled using a -Dmaven.build.cache.remote.enabled=true flag.

Note:
I still need to get a ASF JIRA account in order to make an issue for this request. I've joined the maven mailing list, but I'm still unclear who to email to request this. There are some issues I'd like to investigate further and potentially contribute PR for on this project.

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MNG-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MNG-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the Core IT successfully.

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.

@olamy olamy changed the title Add maven.build.cache.remote.enabled parameter [MBUILDCACHE-46] Add maven.build.cache.remote.enabled parameter Feb 18, 2023
@olamy olamy added the enhancement New feature or request label Feb 18, 2023
@olamy
Copy link
Member

olamy commented Feb 18, 2023

@olamy
Copy link
Member

olamy commented Feb 18, 2023

if remote cache is enabled/disabled via configuration does this correctly override it?
@gnodet I wonder in configuring remote url via cli would be useful as well?

@atsteffen atsteffen requested a review from michael-o March 4, 2023 02:08
return defaultValue;
}
}
return Boolean.parseBoolean(value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with system properties this is redundant, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be accomplished any number of ways, but I decided to go with the micro-optimized form that does not require a string parse to handle the default case.

Copy link
Contributor

@AlexanderAshitkin AlexanderAshitkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be good to:

  1. Write an integration test because flag combinations could result in a not-so-obvious behavior.
  2. [optionally] Precondition all the other remote flags on the remote.enabled.


// remote build first
result = findCachedBuild(mojoExecutions, context);
if (cacheConfig.isRemoteCacheEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write integration tests for this flag. In pr #34, I added Wiremock-based integration tests to verify the remote cache behavior. The same approach could be reused here. It will be good to see a test that checks that remote is disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. For testing flag and xml setting combinations, a lightweight unit test seems prudent. I went ahead and added a unit test for CacheConfigImpl. I tested the initialization and the remote parameters only, but structured it in a way that it should easily accommodate tests around other configurations. A couple integration tests make sense as well, but I thought i'd wait until PR [MBUILDCACHE-25] Fixes N+1 cache processings for forked executions #34 is merged to build off that approach. Tests are a great way to guide meaningful cleanups and refactors, and I feel I need some more time and context to do this at an integration level.

  2. Remote configurations are now preconditioned on any meaningful encompassing configuration behind the CacheConfig interface.

Copy link
Contributor

@AlexanderAshitkin AlexanderAshitkin Mar 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the clarifications, I clicked it!

@atsteffen atsteffen requested a review from michael-o March 16, 2023 12:56
Copy link
Member

@michael-o michael-o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as my concerns have been addressed, I am fine with this change.

@olamy olamy merged commit 9346aaa into apache:master Mar 30, 2023
@jira-importer
Copy link

Resolve #312

1 similar comment
@jira-importer
Copy link

Resolve #312

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants