forked from mamoe/mirai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
161 lines (137 loc) · 5.16 KB
/
build.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
/*
* 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
*/
@file:Suppress("UnstableApiUsage", "UNUSED_VARIABLE", "NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.DokkaBaseConfiguration
import shadow.configureMppShadow
import java.time.LocalDateTime
buildscript {
repositories {
if (System.getProperty("use.maven.local") == "true") {
mavenLocal()
}
mavenCentral()
gradlePluginPortal()
google()
}
dependencies {
classpath("com.android.tools.build:gradle:${Versions.androidGradlePlugin}")
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:${Versions.atomicFU}")
classpath("org.jetbrains.dokka:dokka-base:${Versions.dokka}")
}
}
plugins {
kotlin("jvm") apply false // version Versions.kotlinCompiler
kotlin("plugin.serialization") version Versions.kotlinCompiler apply false
id("com.google.osdetector")
id("org.jetbrains.dokka") version Versions.dokka
id("me.him188.kotlin-jvm-blocking-bridge") version Versions.blockingBridge
id("me.him188.kotlin-dynamic-delegation") version Versions.dynamicDelegation apply false
id("me.him188.maven-central-publish") version Versions.mavenCentralPublish apply false
id("com.gradle.plugin-publish") version "1.1.0" apply false
id("org.jetbrains.kotlinx.binary-compatibility-validator") version Versions.binaryValidator apply false
id("com.android.library") apply false
id("de.mannodermaus.android-junit5") version "1.8.2.1" apply false
}
osDetector = osdetector
BuildSrcRootProjectHolder.value = rootProject
BuildSrcRootProjectHolder.lastUpdateTime = System.currentTimeMillis()
analyzes.CompiledCodeVerify.run { registerAllVerifyTasks() }
allprojects {
group = "net.mamoe"
version = Versions.project
repositories {
if (System.getProperty("use.maven.local") == "true") {
mavenLocal()
}
mavenCentral()
gradlePluginPortal()
google()
}
preConfigureJvmTarget()
afterEvaluate {
configureJvmTarget()
configureMppShadow()
configureEncoding()
configureKotlinTestSettings()
configureKotlinOptIns()
if (isKotlinJvmProject) {
configureFlattenSourceSets()
}
configureJarManifest()
substituteDependenciesUsingExpectedVersion()
}
}
subprojects {
afterEvaluate {
if (project.path == ":mirai-core-api") configureDokka()
if (project.path == ":mirai-console") configureDokka()
}
}
rootProject.configureDokka()
tasks.register("cleanExceptIntellij") {
group = "build"
allprojects.forEach { proj ->
if (proj.name != "mirai-console-intellij") {
// Type mismatch
// proj.tasks.findByName("clean")?.let(::dependsOn)
proj.tasks.findByName("clean")?.let { dependsOn(it) }
}
}
}
extensions.findByName("buildScan")?.withGroovyBuilder {
setProperty("termsOfServiceUrl", "https://gradle.com/terms-of-service")
setProperty("termsOfServiceAgree", "yes")
}
fun Project.configureDokka() {
val isRoot = this@configureDokka == rootProject
if (!isRoot) {
apply(plugin = "org.jetbrains.dokka")
}
tasks.withType<org.jetbrains.dokka.gradle.AbstractDokkaTask>().configureEach {
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
this.footerMessage = """Copyright 2019-${
LocalDateTime.now().year
} <a href="https://github.com/mamoe">Mamoe Technologies</a> and contributors.
Source code:
<a href="https://github.com/mamoe/mirai">GitHub</a>
""".trimIndent()
this.customAssets = listOf(
rootProject.projectDir.resolve("mirai-dokka/frontend/ext.js"),
)
}
}
tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach {
dokkaSourceSets.configureEach {
perPackageOption {
matchingRegex.set("net\\.mamoe\\.mirai\\.*")
skipDeprecated.set(true)
}
for (suppressedPackage in arrayOf(
"""net.mamoe.mirai.internal""",
"""net.mamoe.mirai.internal.message""",
"""net.mamoe.mirai.internal.network""",
"""net.mamoe.mirai.console.internal""",
"""net.mamoe.mirai.console.compiler.common"""
)) {
perPackageOption {
matchingRegex.set(suppressedPackage.replace(".", "\\."))
suppress.set(true)
}
}
}
}
if (isRoot) {
tasks.named<org.jetbrains.dokka.gradle.AbstractDokkaTask>("dokkaHtmlMultiModule").configure {
outputDirectory.set(
rootProject.projectDir.resolve("mirai-dokka/pages/snapshot")
)
}
}
}