Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android gradle - how to search multiple respositories for gradle dependencies

So our group has a private maven repository with a large number of libraries 'in-house'. So there only available on a vpn. bintray and jcenter is available on my vpn. What i want to do is have gradle check for a dependency first on the private maven repo, if not found then search bintray/jcenter for the library. How can i do this ? this is what i have tried:

In the top level build.gradle file i have:

buildscript {
    repositories {
        maven { url "https://myprivateRepo.com/libraries"
    }
        jcenter()
    }

my assumption was that it would first check maven private repo and then check with jcenter afterwards but it seems to not be working, can anyone verify the set up ?

like image 939
j2emanue Avatar asked Oct 28 '25 00:10

j2emanue


1 Answers

You're adding the repositories for your buildscripts (or plugins). You need to add it to your project / dependencies level.

Using it with buildscript will resolve plugins. You need that e.g. if you are using apt: apply plugin: 'com.neenbedankt.android-apt'

Remove the wrapping buildscript block:

repositories {
    maven { url "https://myprivateRepo.com/libraries" }
    mavenCentral()
    jcenter()
}
dependencies {
    compile "my:library:1.0.0"
    // ...
}

Alternatively just set it on the project root build.gradle and apply to all projects like this

allprojects {
    repositories {
        maven { url "https://myprivateRepo.com/libraries" }
        mavenCentral()
        jcenter()
    }
}
like image 83
David Medenjak Avatar answered Oct 29 '25 17:10

David Medenjak