-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.gradle.kts
More file actions
33 lines (27 loc) · 877 Bytes
/
functions.gradle.kts
File metadata and controls
33 lines (27 loc) · 877 Bytes
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
import java.io.FileInputStream
import java.util.Properties
import java.util.regex.Pattern
val loadPropertiesFromFile: (String) -> Properties = { fileName ->
val propertiesFile = rootProject.file(fileName)
val properties = Properties()
properties.load(FileInputStream(propertiesFile))
properties
}
val getCurrentFlavor: () -> String = {
val gradle = gradle
val pattern = Pattern.compile("([A-Z][A-Za-z]+)(Release|Debug)")
var flavor = "prod"
gradle.startParameter.taskNames.any { name ->
val matcher = pattern.matcher(name)
if (matcher.find()) {
flavor = matcher.group(1).toLowerCase()
return@any true
}
false
}
flavor
}
val projectConfigurations: () -> Properties = {
val getCurrentFlavor = getCurrentFlavor()
loadPropertiesFromFile("$getCurrentFlavor.properties")
}