What is "deps" in "implementation deps.support.app_compat"?

Viewed 3444

I was looking in to the google sample for the new architecture component, where I found the the code as below:

dependencies {
    // Support libraries
    implementation deps.support.app_compat
    implementation deps.support.v4
    implementation deps.support.design
    implementation deps.support.cardview

    // Architecture components
    implementation deps.lifecycle.runtime
    implementation deps.lifecycle.extensions
    annotationProcessor deps.lifecycle.compiler
    implementation deps.room.runtime
    annotationProcessor deps.room.compiler

    // Android Testing Support Library's runner and rules
    androidTestImplementation deps.atsl.runner
    androidTestImplementation deps.atsl.rules
    androidTestImplementation deps.room.testing
    androidTestImplementation deps.arch_core.testing

    // Espresso UI Testing
    androidTestImplementation deps.espresso.core
    androidTestImplementation deps.espresso.contrib
    androidTestImplementation deps.espresso.intents

    // Resolve conflicts between main and test APK:
    androidTestImplementation deps.support.annotations
    androidTestImplementation deps.support.v4
    androidTestImplementation deps.support.app_compat
    androidTestImplementation deps.support.design
}

I am not able to understand why they have written all the dependency starting with deps.*. Could anybody help me understand the code. Thanks in advance. Here is the link to the repo.

2 Answers

deps is an instance of Map class that is set on project instance and defined in versions.gradle file. This versions.gradle file is in turn applied in root build.gradle script, hence deps can be used in subprojects.

Adding to @Opal suggestions.

deps is a placeholder defined at the project level.You can find it in here

Say for Dagger2, the deps is defined as follows in the versions.gradle file which is one step above the module level .

*def dagger = [:]
dagger.runtime = "com.google.dagger:dagger:$versions.dagger"
dagger.android = "com.google.dagger:dagger-android:$versions.dagger"
.....

deps.dagger = dagger*

Image if code not well formatted

This way it helps in having the same version applied to all modules for the project . And only the modules which need the particular dependency can declare it at their build.gradle definition.

Related