mirai/build.gradle.kts

162 lines
5.2 KiB
Plaintext
Raw Normal View History

2020-11-01 15:07:32 +08:00
/*
2023-03-19 03:19:01 +08:00
* Copyright 2019-2023 Mamoe Technologies and contributors.
2020-11-01 15:07:32 +08:00
*
* 此源代码的使用受 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.
2020-11-01 15:07:32 +08:00
*
* https://github.com/mamoe/mirai/blob/dev/LICENSE
2020-11-01 15:07:32 +08:00
*/
2021-01-21 10:08:21 +08:00
@file:Suppress("UnstableApiUsage", "UNUSED_VARIABLE", "NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
2020-03-25 12:18:58 +08:00
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.DokkaBaseConfiguration
import shadow.configureMppShadow
import java.time.LocalDateTime
2020-03-01 13:00:34 +08:00
buildscript {
repositories {
if (System.getProperty("use.maven.local") == "true") {
mavenLocal()
}
2020-10-03 13:35:05 +08:00
mavenCentral()
2021-08-25 14:18:40 +08:00
gradlePluginPortal()
2020-03-01 13:00:34 +08:00
google()
}
dependencies {
2020-10-03 13:35:05 +08:00
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}")
2020-03-01 13:00:34 +08:00
}
}
2020-03-23 19:31:22 +08:00
plugins {
kotlin("jvm") apply false // version Versions.kotlinCompiler
kotlin("plugin.serialization") version Versions.kotlinCompiler apply false
2022-05-29 06:03:13 +08:00
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
2020-03-23 19:31:22 +08:00
}
2022-05-29 06:03:13 +08:00
osDetector = osdetector
BuildSrcRootProjectHolder.value = rootProject
BuildSrcRootProjectHolder.lastUpdateTime = System.currentTimeMillis()
2022-05-29 06:03:13 +08:00
analyzes.CompiledCodeVerify.run { registerAllVerifyTasks() }
2020-03-01 13:00:34 +08:00
allprojects {
group = "net.mamoe"
2020-10-03 13:35:05 +08:00
version = Versions.project
2020-03-01 13:00:34 +08:00
repositories {
if (System.getProperty("use.maven.local") == "true") {
mavenLocal()
}
mavenCentral()
2021-08-25 14:18:40 +08:00
gradlePluginPortal()
google()
2020-03-01 13:00:34 +08:00
}
2020-03-25 10:12:24 +08:00
2022-01-04 23:59:13 +08:00
preConfigureJvmTarget()
2020-10-03 13:35:05 +08:00
afterEvaluate {
configureJvmTarget()
configureMppShadow()
configureEncoding()
configureKotlinTestSettings()
configureKotlinOptIns()
2020-10-03 13:35:05 +08:00
if (isKotlinJvmProject) {
configureFlattenSourceSets()
}
configureJarManifest()
substituteDependenciesUsingExpectedVersion()
2021-01-12 18:57:42 +08:00
}
}
2021-01-12 18:57:42 +08:00
subprojects {
afterEvaluate {
2022-01-06 09:10:15 +08:00
if (project.path == ":mirai-core-api") configureDokka()
if (project.path == ":mirai-console") configureDokka()
}
2020-10-03 13:35:05 +08:00
}
rootProject.configureDokka()
2020-09-22 13:23:08 +08:00
2021-02-03 21:28:04 +08:00
tasks.register("cleanExceptIntellij") {
group = "build"
2021-02-06 22:28:09 +08:00
allprojects.forEach { proj ->
if (proj.name != "mirai-console-intellij") {
// Type mismatch
// proj.tasks.findByName("clean")?.let(::dependsOn)
2021-02-06 22:28:09 +08:00
proj.tasks.findByName("clean")?.let { dependsOn(it) }
2020-09-22 18:56:27 +08:00
}
2020-10-03 13:35:05 +08:00
}
2021-02-03 21:28:04 +08:00
}
2021-01-12 18:57:42 +08:00
extensions.findByName("buildScan")?.withGroovyBuilder {
setProperty("termsOfServiceUrl", "https://gradle.com/terms-of-service")
setProperty("termsOfServiceAgree", "yes")
}
2020-10-03 13:35:05 +08:00
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")
)
}
}
2020-10-03 13:35:05 +08:00
}