-
Notifications
You must be signed in to change notification settings - Fork 201
/
manifest.gradle
35 lines (32 loc) · 1.36 KB
/
manifest.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def manifestProperties = "manifest.properties"
def manifestKeys = [
API_KEY : { x -> x },
JUHE_API_KEY: { x -> x },
LEANCLOUD_APP_ID: { x -> x },
LEANCLOUD_APP_KEY: { x -> x }
]
// Find manifest.properties in project root, or in $HOME/.gradle
def f = ["${rootDir}/${manifestProperties}", "${gradle.gradleUserHomeDir}/${manifestProperties}"].find {
file(it).exists()
}
if (f) {
logger.info "Loading manifest properties from ${f}"
def props = new Properties()
props.load(new FileInputStream(f))
// For each property apply it to the release manifest config
manifestKeys.any { k, fn ->
if (!props.containsKey(k)) {
logger.error "Missing property ${k}"
android.defaultConfig.manifestPlaceholders = null
return true
}
android.defaultConfig.manifestPlaceholders[k] = fn(props[k])
logger.info "Setting property ${k}"
}
} else {
logger.info "Missing ${manifestProperties} file"
android.defaultConfig.manifestPlaceholders["API_KEY"] = "${System.env.API_KEY}"
android.defaultConfig.manifestPlaceholders["JUHE_API_KEY"] = "${System.env.JUHE_API_KEY}"
android.defaultConfig.manifestPlaceholders["LEANCLOUD_APP_ID"] = "${System.env.LEANCLOUD_APP_ID}"
android.defaultConfig.manifestPlaceholders["LEANCLOUD_APP_KEY"] = "${System.env.LEANCLOUD_APP_KEY}"
}