Pre-downloading dependencies

I have a very long build (Apache Bigtop) that I need to run in an environment where each build runs on a clean VM and there is no local Maven repository cache. So, from time to time, there’s a network glitch talking to Maven central, and the build fails, and it’s time to start all over.

If I could politely ask Gradle to just do the dependency downloads, I could write a little retry loop to give that a fighting chance to succeed, and then proceed with the rest of the build. Is there a way?

You can add this task to your root project:

task resolveDependencies() {
    doLast {
        allprojects { p ->
            configurations.each { c ->
                if (c.canBeResolved) {
                    println "Downloading dependencies for $p.path - $"

So if I get an error like:

  • What went wrong:
    Execution failed for task ‘:resolveDependencies’.

Could not find property ‘canBeResolved’ on configuration ‘:archives’.

is there a way around?