-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.gradle.kts
102 lines (88 loc) · 3.1 KB
/
settings.gradle.kts
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
fun includeProject(name: String, filePath: String? = null) {
settings.include(name)
val project = project(name)
project.configureProjectDir(filePath)
project.configureBuildFileName(name)
}
fun ProjectDescriptor.configureProjectDir(filePath: String? = null) {
if (filePath != null) {
projectDir = File(rootDir, filePath)
}
if (!projectDir.exists()) {
throw GradleException("Path: $projectDir does not exist. Cannot include project: $name")
}
if (!projectDir.isDirectory) {
throw GradleException("Path: $projectDir is a file instead of a directory. Cannot include project: $name")
}
}
fun ProjectDescriptor.configureBuildFileName(projectName: String) {
val name = projectName.substringAfterLast(":")
/**
* This is mainly to account for sub modules that utilize name spacing to have shorter module/gradle names.
*
* So for example if you have an 'entity' module defined in :foundation:entity and you have a :testing module defined
* within :entity, you can have your gradle/kts file be named either :testing.gradle/kts or :entity-testing.gradle/kts
*/
val secondToLastIndex = lastOrdinalIndexOf(projectName, ':', 2)
val lastIndex = lastOrdinalIndexOf(projectName, ':', 1)
val directParentModule = projectName.substring(secondToLastIndex, lastIndex).trim(':')
buildFileName = "$name.gradle"
if (!buildFile.exists()) {
buildFileName = "$name.gradle.kts"
}
if (!buildFile.exists()) {
buildFileName = "$directParentModule-$name.gradle"
}
if (!buildFile.exists()) {
buildFileName = "$directParentModule-$name.gradle.kts"
}
if (!buildFile.exists()) {
buildFileName = "build.gradle"
}
if (!buildFile.exists()) {
throw GradleException("Build file: build.gradle.kts, $name.gradle.kts, or $directParentModule-$name.gradle.kts does not exist. Cannot include project: $name")
}
}
/**
* Finds the n-th last index within a String
*/
fun lastOrdinalIndexOf(string: String, searchChar: Char, ordinal: Int): Int {
val numberOfOccurrences = string.count { it == searchChar }
if(numberOfOccurrences <= ordinal) {
// the amount of times this character occurs is less than the ordinal you want, returning 0
return 0
}
var found = 0
var index = string.length
do {
index = string.lastIndexOf(searchChar, index - 1)
if (index < 0) {
return index
}
found++
} while (found < ordinal)
return index
}
pluginManagement {
repositories {
google()
gradlePluginPortal()
mavenCentral()
}
}
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
}
rootProject.name = "RapidTouch"
includeProject(":android-app")
includeProject(":data:models")
includeProject(":data:preferences:android-glue")
includeProject(":data:preferences:android-impl")
includeProject(":data:preferences:api")
includeProject(":data:repository:api")
includeProject(":data:repository:android-glue")
includeProject(":data:repository:android-impl")
includeProject(":shared")