-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.gradle.kts
54 lines (44 loc) · 1.38 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
apply(from = "repositories.gradle.kts")
include(":project:core")
include(":project:extension-lib")
include(":project:common-lib")
File(rootDir, "lib").eachDir { include("lib:${it.name}") }
File(rootDir, "extractor").eachDir { include("extractor:${it.name}") }
if (System.getenv("CI") != "true") {
// Local development (full project build)
File(rootDir, "src").eachDir { dir ->
dir.eachDir { subdir ->
include("src:${dir.name}:${subdir.name}")
}
}
} else {
// Running in CI (GitHub Actions)
val chunkSize = System.getenv("CI_CHUNK_SIZE").toInt()
val chunk = System.getenv("CI_CHUNK_NUM").toInt()
// Loads individual extensions
File(rootDir, "src").getChunk(chunk, chunkSize)?.forEach {
include( "src:${it.parentFile.name}:${it.name}")
}
}
fun File.getChunk(chunk: Int, chunkSize: Int): List<File>? {
return listFiles()
?.filter { it.isDirectory }
?.mapNotNull { dir -> dir.listFiles()?.filter { it.isDirectory } }
?.flatten()
?.sortedBy { it.name }
?.chunked(chunkSize)
?.toList()
?.get(chunk)
}
fun File.eachDir(block: (File) -> Unit) {
val files = listFiles() ?: return
for (file in files) {
if (
file.isDirectory &&
file.name != ".gradle" &&
file.name != "build"
) {
block(file)
}
}
}