Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which dependency will Gradle choose given multiple maven repository?

In Gradle project, we can define multiple remote / local Maven repository.

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        jCenter()
        maven { 
            url 'https://example1.mavenrepo.com/public'
        }
        maven {
            url "https://example2.mavenrepo.com/release"
        }
    }

    dependencies {
        classpath 'com.example.mydependencies:mylibrary:1.0.0'
    }
}

If mylibrary exist in all of Maven repo. Which one will Gradle choose? Can I configure Gradle to only download mylibrary in certain Maven repo?

like image 372
aldok Avatar asked Dec 08 '25 18:12

aldok


1 Answers

As you can find in the doc

A project can have multiple repositories. Gradle will look for a dependency in each repository in the order they are specified, stopping at the first repository that contains the requested module.

like image 78
Gabriele Mariotti Avatar answered Dec 10 '25 20:12

Gabriele Mariotti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!