Monday, December 4, 2017

Download and commit gradle dependencies and plugins in Android Studio

Leave a Comment

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.

1 Answers

Answers 1

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.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment