[GRADLE-3107] Gradle re-checks earlier repositories for static version when found in a later repository Created: 19/Jun/14  Updated: 05/Aug/14  Resolved: 05/Aug/14

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 2.1-rc-1

Type: Bug
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Fixed Votes: 0


Gradle should only re-check a repository for a missing module if it has not been found in any subsequent repository.

Currently, for [module1] being located in [repo1, repo2, repo3], Gradle will re-check repo1 and repo2 every 24 hrs, even if [module1] has previously been located in repo3.

Comment by Gradle Forums [ 19/Jun/14 ]

I ended up doing this:

configurations.all {
resolutionStrategy.getCachePolicy().eachModule({ module ->
if (module.getCachedResult() == null) {
module.cacheFor(50, 'years');
} as Action)
resolutionStrategy.getCachePolicy().eachArtifact({ artifact ->
if (artifact.getCachedResult() == null) {
artifact.cacheFor(50, 'years');
} as Action)

Not sure if it worked yet, I guess I'll know in 24 hours..

Comment by Gradle Forums [ 19/Jun/14 ]

Unfortunately, that did not seem to do the trick. 24 hours later, I got a bunch of "Resource missing." again..

So our situation is that we have a number of repositories (say 5) and for a few of them we have a number of Ivy patterns to try and for each one it takes a while to get the 404. So once per day we take a 30 minute hit when building our projects.

As far as I can understand, what's happening is that it rechecks the repos that didn't have the dependency, although we have one repo (maybe further down the list) that actually does have the dependency downloaded already. It would be great if we could check for this fact before attempting to refresh. To be clear, these are all release versions and not snapshots or dynamic versions.

Any ideas?


Comment by Gradle Forums [ 19/Jun/14 ]

“I like hearing myself talk. It is one of my greatest pleasures. I often have long conversations all by myself, and I am so clever that I sometimes don't understand a single word of what I am saying.”

― Oscar Wilde, The Remarkable Rocket

I figured out that adding the same block of code into the buildscript block removed the last "Resource missing"s.

Two questions remain:
1. Would it be an easy fix to make this configurable?
2. Would it make sense to first check if an artifact exists (cached) in any of the repositories before re-checking repositories where the artifact is missing?


Comment by Viktor Nordling [ 24/Jun/14 ]

I've pushed a fix for this here: https://github.com/viktornordling/gradle/commit/59481bb20ab73ea101b3df8b9943267d6c0789df

I'm not sure if I've followed all the guidelines for what to do when pushing a fix, so please let me know what I'm missing.

One thing that definitely needs to be fixed is the "@since ?", not sure what to put there.

Also, the build failed on both master and release with a fresh clone, so I haven't been able to successfully run a build with my change, although I've installed it locally and tested that it works.

Comment by Viktor Nordling [ 14/Jul/14 ]

A PR has been submitted for this: https://github.com/gradle/gradle/pull/298

Generated at Wed Jun 30 12:40:10 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.