How are hash values for Gradle repositories calculated

The new Gradle cache seems to store things under ~/.gradle/caches/artifacts-4/group/name/HASH/jars/name-version.jar. What determines the HASH? Sometimes, it seems to change if I change my repository definition - but sometimes not. It just changed again, and the only thing I did (I think) was to upgrade to a new snapshot of M6. Repository isolation is wonderful and all that - but most of my developers are remote, and we have hundreds of megs of dependencies. I can’t have them be redownloading dependencies just because some byte changed somewhere in the repository definition.

What does Gradle use to generate the hash? How can I make sure not to touch it? Better yet, is there a way to override the hash and manually specify a repository ID to use in its place?

1 Like

To answer your specific question, repository hashes are constructed using the ‘getId()’ method of the WharfResolverMetadata class.

However, with Milestone 6 you would have downloaded everything again regardless of repository hash values: see this forum post for an explanation why.

In the works is a more efficient implementation of caching, which will separate meta-data caching (resolvers, modules, dependencies, etc) from artifact caching (which is really just a mapping from url => hashcode => artifact). We believe this will introduce stability to the caching structure, allowing us to evolve the meta-data format without requiring the artifacts to be downloaded multiple times.

Thanks for your patience as we work on our caching infrastructure. Believe me, we are aware of the current limitations and are working toward resolving them.

I’m aware of the change from artifacts-3 to artifacts-4 - that’s not what I’m referring to. For some reason, each of my artifacts under artifacts-4 has 3 different hash directories. I guess each time it’s because I’ve changed something in my resolver configuration (though at least once it changed when I didn’t expect it to), but it’s really annoying.

I understand the desire to isolate resolvers to make sure the right artifact is downloaded, but in my environment (a single copy of the repository accessed over various mechanisms), it’s just causing problems.

I thought I might be able to monkey-patch a workaround, but I’m not having any success. Here’s what I’m trying:

buildscript {

dependencies {

classpath gradleApi()



org.jfrog.wharf.ivy.model.WharfResolverMetadata.metaClass.getId = { ‘repository’ }

If I call ‘new WharfResolverMetadata().getId()’, I get “repository.” However, Gradle is still using the hash directories. Am I patching WharfResolverMetadata in the wrong classloader (or JVM instance or …)? Is there any way to do this?