forked from mamoe/mirai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.gradle.kts
188 lines (153 loc) · 6.83 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
* Copyright 2019-2023 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
import java.util.*
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
pluginManagement {
repositories {
if (System.getProperty("use.maven.local") == "true") { // you can enable by adding `systemProp.use.maven.local=true` in 'gradle.properties'.
mavenLocal()
}
gradlePluginPortal()
mavenCentral()
google()
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.4.0"
}
rootProject.name = "mirai"
runCatching { rootProject.projectDir.resolve("local.properties").let { if (!it.exists()) it.createNewFile() } }
val localProperties = Properties().apply {
rootProject.projectDir.resolve("local.properties").takeIf { it.exists() }?.bufferedReader()?.use {
load(it)
}
}
/**
* Projects included so far
*/
val allProjects = mutableListOf<ProjectDescriptor>()
fun includeProject(projectPath: String, dir: String? = null) {
if (!getLocalProperty("projects." + projectPath.removePrefix(":") + ".enabled", true)) return
include(projectPath)
if (dir != null) project(projectPath).projectDir = file(dir)
allProjects.add(project(projectPath))
}
fun includeConsoleProject(projectPath: String, dir: String? = null) =
includeProject(projectPath, "mirai-console/$dir")
includeProject(":mirai-core-utils")
includeProject(":mirai-core-api")
includeProject(":mirai-core")
includeProject(":mirai-core-mock")
includeProject(":mirai-core-all")
includeProject(":mirai-bom")
includeProject(":mirai-dokka")
includeProject(":mirai-deps-test")
if (getLocalProperty("projects.mirai-logging.enabled", true)) {
includeProject(":mirai-logging-log4j2", "logging/mirai-logging-log4j2")
includeProject(":mirai-logging-slf4j", "logging/mirai-logging-slf4j")
includeProject(":mirai-logging-slf4j-simple", "logging/mirai-logging-slf4j-simple")
includeProject(":mirai-logging-slf4j-logback", "logging/mirai-logging-slf4j-logback")
}
// mirai-core-api depends on this
includeConsoleProject(":mirai-console-compiler-annotations", "tools/compiler-annotations")
if (getLocalProperty("projects.mirai-console.enabled", true)) {
includeConsoleProject(":mirai-console", "backend/mirai-console")
includeConsoleProject(":mirai-console.codegen", "backend/codegen")
includeConsoleProject(":mirai-console-frontend-base", "frontend/mirai-console-frontend-base")
includeConsoleProject(":mirai-console-terminal", "frontend/mirai-console-terminal")
includeConsoleIntegrationTestProjects()
includeConsoleProject(":mirai-console-compiler-common", "tools/compiler-common")
includeConsoleProject(":mirai-console-intellij", "tools/intellij-plugin")
includeConsoleProject(":mirai-console-gradle", "tools/gradle-plugin")
} else {
// if mirai-console is disabled, disable all relevant projects
}
//includeConsoleFrontendGraphical()
includeProject(":ci-release-helper")
includeBinaryCompatibilityValidatorProjects()
/**
* Configures a project `:validator:path-to-project:target-name` for binary compatibility validation.
*
* To enable validation for a project,
* create a subdirectory with name of the target under "compatibility-validation",
* then sync **twice**. See `:mirai-core-api` for an example.
*
* **Note**: This function depends on [allProjects], and should be used at the end.
*/
fun includeBinaryCompatibilityValidatorProjects() {
val result = mutableListOf<ProjectDescriptor>()
for (project in allProjects) {
val validationDir = project.projectDir.resolve("compatibility-validation")
if (!validationDir.exists()) continue
validationDir.listFiles().orEmpty<File>().forEach { dir ->
if (dir.resolve("build.gradle.kts").isFile) {
// Also change: BinaryCompatibilityConfigurator.getValidatorDir
val path = ":validator" + project.path + "-validator:${dir.name}"
include(path)
project(path).projectDir = dir
// project(path).name = "${project.name}-validator-${dir.name}"
result.add(project(path))
}
}
}
}
fun includeConsoleLegacyFrontendProjects() {
println("JDK version: ${JavaVersion.current()}")
if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
includeConsoleProject(":mirai-console-graphical", "frontend/mirai-console-graphical")
} else {
println("当前使用的 JDK 版本为 ${System.getProperty("java.version")}, 请使用 JDK 9 以上版本引入模块 `:mirai-console-graphical`\n")
}
}
fun includeConsoleIntegrationTestProjects() {
includeConsoleProject(":mirai-console.integration-test", "backend/integration-test")
val consoleIntegrationTestSubPluginBuildGradleKtsTemplate by lazy {
rootProject.projectDir
.resolve("mirai-console/backend/integration-test/testers")
.resolve("tester.template.gradle.kts")
.readText()
}
@Suppress("SimpleRedundantLet")
fun includeConsoleITPlugin(prefix: String, path: File) {
path.resolve("build.gradle.kts").takeIf { !it.isFile }?.let { initScript ->
initScript.writeText(consoleIntegrationTestSubPluginBuildGradleKtsTemplate)
}
val projectPath = "$prefix${path.name}"
include(projectPath)
project(projectPath).projectDir = path
path.listFiles()?.asSequence().orEmpty()
.filter { it.isDirectory }
.filter { it.resolve(".nested-module.txt").exists() }
.forEach { includeConsoleITPlugin("${projectPath}:", it) }
}
rootProject.projectDir
.resolve("mirai-console/backend/integration-test/testers")
.listFiles()?.asSequence().orEmpty()
.filter { it.isDirectory }
.forEach { includeConsoleITPlugin(":mirai-console.integration-test:", it) }
}
fun getLocalProperty(name: String): String? {
return localProperties.getProperty(name)
}
fun getLocalProperty(name: String, default: String): String {
return localProperties.getProperty(name) ?: default
}
fun getLocalProperty(name: String, default: Int): Int {
return localProperties.getProperty(name)?.toInt() ?: default
}
fun getLocalProperty(name: String, default: Boolean): Boolean {
return localProperties.getProperty(name)?.toBoolean() ?: default
}