-
Notifications
You must be signed in to change notification settings - Fork 984
Expand file tree
/
Copy pathproperties.gradle.kts
More file actions
47 lines (42 loc) · 1.26 KB
/
properties.gradle.kts
File metadata and controls
47 lines (42 loc) · 1.26 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
import java.io.File
import java.util.*
var localProps: Properties? = null
var rootProps: Properties? = null
// CLI properties: gradle.startParameter.projectProperties
val cliProps = gradle.startParameter.projectProperties
fun readProperties (fileName: String): Properties = Properties().apply {
val file = if (rootDir.name == "buildSrc") {
File("${rootDir.parentFile}/${fileName}")
} else {
File("${rootProject.projectDir}/${fileName}")
}
val f = file.canonicalFile
if (!f.exists()) {
error(f.absolutePath)
} else {
f.inputStream().use {
load(it)
}
}
}
fun resolveGradleProperty(name: String): String? {
return providers.gradleProperty(name).orNull ?: let {
cliProps[name] ?: System.getProperty(name) ?: let {
if (localProps == null) {
localProps = readProperties("local.properties")
}
localProps!![name]?.toString() ?: let {
if (rootProps == null) {
rootProps = readProperties("gradle.properties")
}
rootProps!![name]?.toString()
}
}
}
}
val extension = resolveGradleProperty("tgx.extension") ?: "none"
if (extension != "none" && extension != "hms") {
error("Unknown extension: ${extension}")
}
extra["huawei"] = (extension == "hms")
extra["extension"] = extension