How can I specify gradle project properties in gradle.properties file?

末鹿安然 提交于 2019-12-11 04:09:35

问题


Is it possible to specify project properties such as name in gradle.properties file so will be possible to access them from build.gradle by using project.name?

I've tried with no luck:

name=some
project.name=some
org.gradle.project.name=some

回答1:


You can do it.

For example in your root gradle.properties file you can have:

VERSION_NAME=2.0.2

Then in your build.gradle file (in the root folder) you can have for example:

allprojects {
    version = VERSION_NAME
}

If you would like to use it in your module build.gradle file you can have:

android {

    defaultConfig {
        versionName project.VERSION_NAME  
    }
}



回答2:


These properties won't be set automatically - see the docs. It can be done with settings.gradle.



来源:https://stackoverflow.com/questions/29393536/how-can-i-specify-gradle-project-properties-in-gradle-properties-file

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