问题
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