Android - Read build.gradle properties inside class

Viewed 12234

I would like to have access to build.gradle properties so I can automatize some processes in my app.

This is the structure i have at the moment:

rootProject/build.gradle

buildscript {
    ext {
        buildTools = "25.0.2"
        minSdk = 16
        compileSdk = 23
        targetSdk = 23

        versions = [supportLib         : '25.0.0',
                    multidex           : '1.0.1',
                    playServices       : '10.0.1']
        libs = [appcompat            : "com.android.support:appcompat-v7:$versions.supportLib",
               design               : "com.android.support:design:$versions.supportLib"]

        .... Other libraries and setup....

    }
}

rootProject/app/build.gradle

...
dependencies {
    // Support libraries
    compile libs.appcompat
    compile libs.design
    .....
}

I would like to access both on Java and build.gradle side the properties version and libs variables. How can I achieve this?

2 Answers
Related