Gradle build for set of Android projects (including libraries)

China☆狼群 提交于 2019-12-01 11:04:58
Gabriele Mariotti

You can use your build.gradle in root, or you can define some values in gradle.properties in root folder to achieve your scope.

For example:

root/build.gradle:

ext {
    compileSdkVersion = 19
    buildToolsVersion = "19.0.3"
}

module/build.gradle:

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
}

OR using properties

root/gradle.properties:

VERSION_NAME=1.0.1
VERSION_CODE=11

module/build.gradle:

android {

    defaultConfig {
        versionName project.VERSION_NAME
        versionCode Integer.parseInt(project.VERSION_CODE)

    }

Other option would be as Peter Niederwieser suggested

either add some logic to the root script to apply the right plugin to each subproject (there are different ways to do this), or move the common parts into a script named android.gradle and apply that script to each subproject after applying the correct plugin for that project (all in the subproject's build script).

Related docs is Chapter 56. Multi-project Builds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!