简书链接:模块化开发1笔记变量配置的定义与读取
文章字数:79,阅读全文大约需要1分钟

1
2
3
4
5
6
7
8

apply from: 'config.gradle'
if(asApp.asBoolean()){
print "asApp "
}else{

print " not as App "
}

config.gradle

1
2
3
4
5
6
7
8
9
10
print "config.gradle被执行"
ext {
authorInfo = [
name: "qssq666"
]
DEBUGMODE = true
companyInfo = [
"address" : "shenzhen",
"address1": "test1"]
}

用冒号的是键值对,ext{}表示展开,固定的, =赋值的表示变量,

1
2
printf("name:"+authorInfo.name)
printf("name:"+authorInfo.get("name"))

image.png

读取gradle.properties内容

定义asApp=false
读取