-
Notifications
You must be signed in to change notification settings - Fork 32
/
settings.gradle.kts
93 lines (75 loc) · 2.9 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
/*
* Copyright (c) 2020 Proton Technologies AG
* This file is part of Proton Technologies AG and ProtonCore.
*
* ProtonCore is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ProtonCore is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProtonCore. If not, see <https://www.gnu.org/licenses/>.
*/
rootProject.name = "ProtonCore"
val (projects, modules) = rootDir.projectsAndModules()
val namedProjects = projects.map { it to it.replace("/", "-") }
val namedModules = modules.map { it to it.drop(1).replace(":", "-") }
println("Projects: ${namedProjects.sortedBy { it.first }.joinToString { "${it.first} as ${it.second}" } }")
println("Modules: ${namedModules.sortedBy { it.first }.joinToString { "${it.first} as ${it.second}" } }")
for ((p, n) in namedProjects) includeBuild(p) { name = n }
for (m in modules) include(m)
for (m in namedModules) project(m.first).name = m.second
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
maven("https://plugins.gradle.org/m2/")
}
}
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 }
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> = 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 formattedProjects to modules
}
buildCache {
local {
removeUnusedEntriesAfterDays = 3
}
}