-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.gradle.kts
executable file
·110 lines (96 loc) · 3.45 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
103
104
105
106
107
108
109
110
import org.gradle.kotlin.dsl.support.listFilesOrdered
rootProject.name = "MindSync"
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
enableFeaturePreview("STABLE_CONFIGURATION_CACHE")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
dependencyResolutionManagement {
repositories {
mavenCentral()
google()
maven("https://androidx.dev/storage/compose-compiler/repository")
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven("https://maven.pkg.jetbrains.space/public/p/ktor/eap")
}
}
pluginManagement {
includeBuild("build-logic")
repositories {
mavenCentral()
google()
gradlePluginPortal()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
}
plugins {
id("com.gradle.enterprise") version "3.15.1"
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
}
// Keep in sync with build-logic/settings.gradle.kts
buildCache {
local {
directory = rootDir.resolve(".gradle/build-cache")
}
}
val defaultBuildGradleKts = "build.gradle.kts"
fun isGradleKtsProjectDirectory(directory: File) =
directory.isDirectory &&
(
directory.resolve(defaultBuildGradleKts).exists() ||
directory.resolve("${directory.name}.gradle.kts").exists()
) &&
directory.name !in excludedProjects
fun includeGradleProjectsRecursively(directoryPath: String) {
val baseDirectory = rootDir.resolve(directoryPath)
baseDirectory.walkTopDown()
.maxDepth(1)
.filter { it.isDirectory }
.forEach { subDir ->
includeProjectsInDirectory(subDir.path)
}
}
fun includeProject(dir: File) {
println("\uD83D\uDCE6 Loading submodule: ${dir.name}")
val projectName = calculateProjectName(dir)
include(projectName)
val prj = project(":$projectName")
prj.projectDir = dir
prj.buildFileName = if (dir.resolve("${dir.name}.gradle.kts").exists()) {
"${dir.name}.gradle.kts"
} else {
defaultBuildGradleKts
}
require(prj.projectDir.isDirectory) { "Project '${prj.path} must have a ${prj.projectDir} directory" }
require(prj.buildFile.isFile) {
"Project '${prj.path} must have a ${prj.buildFile} build script file or ${prj.buildFile.name}.gradle.kts"
}
}
fun calculateProjectName(dir: File): String {
val projectName = dir.relativeTo(rootDir).path.replace("/", ":")
println("\uD83D\uDFE2 Project name: $projectName")
return if (projectName.startsWith(":")) projectName.substring(1) else projectName
}
fun includeProjectsInDirectory(directoryPath: String) {
val baseDirectory = rootDir.resolve(directoryPath)
println("\uD83D\uDFE3 Loading projects from \uD83D\uDCC2 $baseDirectory")
baseDirectory.listFilesOrdered()
.filter { isGradleKtsProjectDirectory(it) }
.forEach { projectDirectory ->
includeProject(projectDirectory)
}
}
val excludedProjects = listOf("iosApp")
val projects = listOf("apps")
projects.forEach { includeGradleProjectsRecursively(it) }
includeProject(file( "shared"))
includeProject(file("documentation"))
if (!System.getenv("CI").isNullOrEmpty() && !System.getenv("BUILD_SCAN_TOS_ACCEPTED")
.isNullOrEmpty()
) {
gradleEnterprise {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
tag("CI")
}
}
}