-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathsettings.gradle.kts
90 lines (74 loc) · 2.43 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
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
buildCache {
local {
removeUnusedEntriesAfterDays = 30
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
maven { url = uri("https://dl.bintray.com/asf/asf") }
maven { url = uri("https://dl.bintray.com/aptoide/Aptoide") }
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots") }
// needed for pincode Lollipin
maven { url = uri("https://github.com/omadahealth/omada-nexus/raw/master/release") }
// VK ID and Vk Pay
maven {
url = uri("https://artifactory-external.vkpartner.ru/artifactory/superappkit-maven-public/")
}
}
}
val (projects, modules) = rootDir.projectsAndModules()
println("Projects:\n\t- ${projects.sortedBy { it }.joinToString("\n\t- ") { it }}")
println("Modules:\n\t- ${modules.sortedBy { it }.joinToString("\n\t- ") { it }}")
for (project in projects) includeBuild(project)
for (module in modules) include(module)
fun File.projectsAndModules(): Pair<Set<String>, Set<String>> {
val blacklist = setOf(
".git",
".gradle",
".idea",
"buildSrc",
"config",
"build",
"src"
)
fun File.childrenDirectories() = listFiles { _, name -> name !in blacklist }
?.filter { it.isDirectory }
.orEmpty()
fun File.isProject() = File(this, "settings.gradle.kts").exists() ||
File(this, "settings.gradle").exists()
fun File.isModule() = !isProject() &&
(File(this, "build.gradle.kts").exists() || File(this, "build.gradle").exists())
val modules = mutableSetOf<String>()
val projects = mutableSetOf<String>()
fun File.find(name: String? = null, includeModules: Boolean = true): List<File> {
return childrenDirectories().flatMap {
val newName = (name ?: "") + it.name
when {
it.isProject() -> {
projects += newName
it.find("$newName:", includeModules = false)
}
it.isModule() && includeModules -> {
modules += ":$newName"
it.find("$newName:")
}
else -> it.find("$newName:")
}
}
}
find()
// we need to replace here since some Projects have a Module as a parent folder
val formattedProjects = projects.map { it.replace(":", "/") }.toSet()
return Pair(formattedProjects, modules)
}