Search code examples
androidgradlebuild.gradlejcenter

android build.gradle file for app - what is default repository


In my build.gradle file for the top level build.gradle file - jcenter () is not specifically written. so i have a the following in the top level build.gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        //jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
    }
}

allprojects {
    repositories {
        //jcenter()
    }
}

somehow all my dependencies i have defined in my module are still found and the app runs fine. Can i assume that jcenter() is the default repo then if none is found ? is it used by default ? Otherwise how are my dependencies coming. Also if i wanted to over ride jcenter() to use another repo how would i do it.

so what if i had the following custom repository:

buildscript {
    repositories {
        maven {
            url "https://someEnterpriseRepository.com/myRepo"
        }
    }

does that mean it checks maven custom repo first and then checks jcenter() if dependency is not found ? BTW, i have cleared the IDE cache from file-->invalidate cache before testing all this.


Solution

  • The only two reasons your build might work without a clearly stated repository in the script are:

    1. Gradle uses an init script that defines a repository transparently.
    2. The dependencies come from your local cache.