Jon
Jon

Reputation: 1499

gradle - task to only download maven dependencies

Is there a task in gradle that will simply download the dependencies from the maven repository?

The dependencies in my build.gradle file are specified as follows.

dependencies {
    compile 'com.google.firebase:firebase-ads:9.8.0'
}

The only way I have been able to do this is to actually perform a build (e.g. ./gradlew build ), however that takes too much time if all I want to do retrieve the dependencies.

Upvotes: 3

Views: 5683

Answers (2)

wizawu
wizawu

Reputation: 2081

I learned how to do it thanks to @louis-jacomet.

With a build.gradle file like this,

repositories {
    jcenter()
}

configurations {
    scm
}

dependencies {
    scm "com.google.code.gson:gson:2.8.5"
}

task lib(type: Copy) {
    into "/path/to/download"
    from configurations.scm
}

and start downloading by gradle lib. Surely you can use other task name than lib.

Upvotes: 1

Louis Jacomet
Louis Jacomet

Reputation: 14500

You can run ./gradlew dependencies which will print a report about the dependencies of your build, and to do so will have to resolve them.

Note however that the download happens only if Gradle does not have them in cache already.

Upvotes: 16

Related Questions