apache / apache/maven-resolver
[MRESOLVER-634] updatePolicy is ignored for version-range metadata requests
- Dominant language
- Java
- Stars
- 152
- Forks
- 160
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 49
Description
**[Bas van Erp](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=JIRAUSER300062)** opened **[MRESOLVER-634](https://issues.apache.org/jira/browse/MRESOLVER-634?redirect=false)** and commented
maven-metadata.xml is refetched for every dependency which uses version-ranges if the `resolver-status.properties` file's "lastUpdated" property is _before_ last midnight (local time, for some reason).
It ignores all updatePolicy configs in settings.xml
I have tried diving into the code, but as I'm not a programmer, I couldn't really wrap my head around it.
## Setup
* Have a `settings.xml` with `never` for everything.
* Have a `pom.xml` with a dependency which uses a version-range.
* Run `mvn validate` to trigger the resolver and make sure all metadata and dependencies are downloaded and the Maven cache is warmed up.
## Correct
* Use https://www.epochconverter.com/ to create a millisecond timestamp for **today** (local-time): 00:00:01
* Replace the `xxx.xml.lastUpdated=###` timestamp in the `resolver-status.properties` file of the dependency which is referenced in the pom.xml
* Run `mvn validate -X` to trigger the resolver. It should return something like: "Skipped remote request for x:y/maven-metadata.xml, locally cached metadata up-to-date"
* Good
## Wrong
* Use https://www.epochconverter.com/ to create a millisecond timestamp for **yesterday** (local-time): 23:59:59
* Replace the `xxx.xml.lastUpdated=###` timestamp in the `resolver-status.properties` file of the dependency which is referenced in the pom.xml
* Run `mvn validate` to trigger the resolver.
* The resolver will download the maven-metadata.xml again. Every day.
## Impact
We have some dependencies which use version ranges for a lot of transitive dependencies, and I hate it for multiple reasons. But to add insult to injury, every night the first build will refetch all these metadata files in order to see if version resolution needs to change. ;)
I have found no way to block this, since version-ranges seem to bypass repository updatePolicy settings.
---
**Affects:** 1.9.22
**Issue Links:**
- [MNG-5997](https://issues.apache.org/jira/browse/MNG-5997) Continuous download of maven-metadata.xml for version ranges.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the behavior with the described settings.xml and pom.xml setup, editing the resolver-status.properties timestamp and running mvn validate with and without -X. Trace how version-range metadata requests handle updatePolicy; done when updatePolicy=never prevents the daily maven-metadata.xml refetch and the debug output reports the cached metadata as up to date.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100