nosh
nosh

Reputation: 600

Download and commit gradle dependencies and plugins in Android Studio

This is an excerpt from a build.gradle file for one of my modules. I'm using android-studio-1.5.1 and gradle 2.10.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:design:23.2.1'
    compile 'com.google.android.gms:play-services-gcm:9.0.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
}

I also have classpath 'com.google.gms:google-services:3.0.0' in the project level build.gradle file.

I'm trying to gather all the associated jars into a directory which I can commit to my git repo. Something like:

task copyRuntimeLibs(type: Copy) {
    into "${projectDir}/libs"
    from configurations.compile
}

(This does not work) Also, I'm not trying to download the sources or javadocs.

I need to be able to commit all dependencies so that the project can be shared on an intranet without internet access.

Upvotes: 2

Views: 400

Answers (1)

lance-java
lance-java

Reputation: 27986

I've written a plugin which will download all jars and poms. See the code here to download all jars and all poms from a Gradle Configuration

Note: There's a failing test here which shows that the parent pom's are not being downloaded. I've raised an issue here on Gradle's github.

I will likely improve the plugin to invoke the Maven Model Builder APIs to get the parent poms.

FYI - I've already integrated the ModelBuilder APIs successfully with Gradle (see here and here) so shouldn't be too difficult.

Upvotes: 1

Related Questions