How can I force caching of dependencies from a file-based repo?


(Til Schneider) #1

My project has dependencies to a maven repo which is mounted to my file system and referenced using a file URL:

repositories {
    maven {
        url 'file:/Volumes/Repos/maven.repo/'
    }
    mavenCentral()
}

When I build the project, the dependencies from mavenCentral are cached locally, which allows me to work offline after I built the project once before.

Unfortunately, the dependencies from the file-based repo are not cached. So my build breaks when I try to run it at home where “/Volumes/Repos” is not mounted.

Can I force gradle to cache dependencies from my file-based repo?

I would like to do something like that:

repositories {
    maven {
        url 'file:/Volumes/Repos/maven.repo/'
        useCache true
    }
    mavenCentral()
}

(Peter Niederwieser) #2

As far as I know, artifact caching isn’t supported for file-based repositories.


(Til Schneider) #3

OK. Can I turn this question into a feature request?

Or is there any workaround? E.g. adding a task which copies the dependencies to the local maven repo (~/.m2)?


(Peter Niederwieser) #4

This is similar to GRADLE-1964, but I’ve created GRADLE-2948 since this time it’s about Maven repos. I’m not aware of a workaround, but I’d consider switching to a binary repository such as Artifactory or Nexus.


(Christian K.) #5

We are facing a similar issue, is anyone here aware of a workaround? The workaround mentioned in http://issues.gradle.org/browse/GRADLE-1964 seems to be Ivy specific.