mirai/mirai-core/build.gradle.kts

182 lines
5.7 KiB
Plaintext
Raw Normal View History

2020-11-01 15:07:32 +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
*/
2019-11-15 10:39:00 +08:00
@file:Suppress("UNUSED_VARIABLE")
2021-12-28 01:15:56 +08:00
import BinaryCompatibilityConfigurator.configureBinaryValidators
import shadow.relocateCompileOnly
import shadow.relocateImplementation
2020-10-03 13:35:05 +08:00
2019-10-30 23:00:29 +08:00
plugins {
kotlin("multiplatform")
id("kotlinx-atomicfu")
2020-03-24 10:01:03 +08:00
kotlin("plugin.serialization")
id("me.him188.kotlin-jvm-blocking-bridge")
id("me.him188.kotlin-dynamic-delegation")
// id("me.him188.maven-central-publish")
2019-11-15 10:39:00 +08:00
`maven-publish`
2019-10-30 23:00:29 +08:00
}
description = "Mirai Protocol implementation for QQ Android"
2019-10-30 23:00:29 +08:00
2019-11-06 21:22:23 +08:00
kotlin {
explicitApi()
apply(plugin = "explicit-api")
configureJvmTargetsHierarchical("net.mamoe.mirai.internal")
2019-10-30 23:00:29 +08:00
optInForAllSourceSets("net.mamoe.mirai.utils.MiraiExperimentalApi")
optInForAllSourceSets("net.mamoe.mirai.utils.MiraiInternalApi")
optInForAllSourceSets("net.mamoe.mirai.LowLevelApi")
optInForAllSourceSets("kotlinx.serialization.ExperimentalSerializationApi")
2020-07-20 15:06:30 +08:00
sourceSets.apply {
2019-11-08 20:51:40 +08:00
2021-02-01 12:23:04 +08:00
val commonMain by getting {
2019-11-23 22:34:57 +08:00
dependencies {
api(project(":mirai-core-api"))
2022-05-17 16:43:09 +08:00
api(`kotlinx-serialization-core`)
api(`kotlinx-serialization-json`)
api(`kotlinx-coroutines-core`)
2020-10-03 13:35:05 +08:00
implementation(`kt-bignum`)
implementation(project(":mirai-core-utils"))
2022-05-17 16:43:09 +08:00
implementation(`kotlinx-serialization-protobuf`)
implementation(`kotlinx-atomicfu`)
2022-11-03 03:28:04 +08:00
// runtime from mirai-core-utils
relocateCompileOnly(`ktor-io_relocated`)
2022-11-03 03:28:04 +08:00
// relocateImplementation(`ktor-http_relocated`)
// relocateImplementation(`ktor-serialization_relocated`)
// relocateImplementation(`ktor-websocket-serialization_relocated`)
2019-11-23 22:34:57 +08:00
}
2019-11-22 19:10:10 +08:00
}
2020-07-20 17:21:00 +08:00
2020-10-03 13:35:05 +08:00
commonTest {
2019-11-23 22:34:57 +08:00
dependencies {
implementation(kotlin("script-runtime"))
2022-06-14 19:43:43 +08:00
implementation(`kotlinx-coroutines-test`)
2022-05-17 16:43:09 +08:00
api(yamlkt)
}
}
findByName("jvmBaseMain")?.apply {
2022-05-17 16:43:09 +08:00
dependencies {
implementation(`log4j-api`)
implementation(`netty-handler`)
2022-06-11 19:55:25 +08:00
api(`kotlinx-coroutines-jdk8`) // use -jvm modules for this magic target 'jvmBase'
2019-11-23 22:34:57 +08:00
}
2019-11-13 19:49:21 +08:00
}
2019-10-31 23:11:55 +08:00
findByName("jvmBaseTest")?.apply {
2022-05-19 03:54:47 +08:00
dependencies {
implementation(`kotlinx-coroutines-debug`)
}
}
findByName("androidMain")?.apply {
dependencies {
if (rootProject.property("mirai.android.target.api.level")!!.toString().toInt() < 23) {
// Ship with BC if we are targeting 23 or lower where AndroidKeyStore is not stable enough.
// For more info, read `net.mamoe.mirai.internal.utils.crypto.EcdhAndroidKt.create` in `androidMain`.
implementation(bouncycastle)
}
}
}
// For Android with JDK
findByName("androidTest")?.apply {
dependencies {
implementation(bouncycastle)
2019-12-07 00:17:34 +08:00
}
}
// For Android with SDK
findByName("androidUnitTest")?.apply {
dependencies {
implementation(bouncycastle)
}
}
2019-12-07 00:17:34 +08:00
findByName("jvmMain")?.apply {
2019-11-15 10:39:00 +08:00
dependencies {
implementation(bouncycastle)
2020-10-03 13:35:05 +08:00
// api(kotlinx("coroutines-debug", Versions.coroutines))
2019-11-15 10:39:00 +08:00
}
}
findByName("jvmTest")?.apply {
2019-11-23 22:34:57 +08:00
dependencies {
api(`kotlinx-coroutines-debug`)
2021-02-01 12:23:04 +08:00
// implementation("net.mamoe:mirai-login-solver-selenium:1.0-dev-14")
2019-11-15 10:39:00 +08:00
}
}
2022-05-17 16:43:09 +08:00
2022-11-03 03:28:04 +08:00
// Kt bignum
findByName("jvmBaseMain")?.apply {
dependencies {
relocateImplementation(`kt-bignum_relocated`)
}
}
2022-11-03 03:28:04 +08:00
// Ktor
findByName("commonMain")?.apply {
dependencies {
compileOnly(`ktor-io`)
implementation(`ktor-client-core`)
}
}
findByName("jvmBaseMain")?.apply {
// relocate for JVM like modules
2022-11-03 03:28:04 +08:00
dependencies {
relocateCompileOnly(`ktor-io_relocated`) // runtime from mirai-core-utils
relocateImplementation(`ktor-client-core_relocated`)
}
}
findByName("jvmBaseMain")?.apply {
dependencies {
relocateImplementation(`ktor-client-okhttp_relocated`)
}
}
2019-11-15 10:39:00 +08:00
}
2020-02-16 13:54:42 +08:00
}
2020-03-24 10:01:03 +08:00
atomicfu {
transformJvm = false
}
if (tasks.findByName("androidMainClasses") != null) {
tasks.register("checkAndroidApiLevel") {
doFirst {
analyzes.AndroidApiLevelCheck.check(
buildDir.resolve("classes/kotlin/android/main"),
project.property("mirai.android.target.api.level")!!.toString().toInt(),
project
)
}
group = "verification"
this.mustRunAfter("androidMainClasses")
2021-02-25 00:12:58 +08:00
}
tasks.findByName("androidTest")?.dependsOn("checkAndroidApiLevel")
2021-02-25 00:12:58 +08:00
}
2021-12-28 01:15:56 +08:00
configureMppPublishing()
configureBinaryValidators(setOf("jvm", "android").filterTargets())
//mavenCentralPublish {
// artifactId = "mirai-core"
// githubProject("mamoe", "mirai")
// developer("Mamoe Technologies", email = "support@mamoe.net", url = "https://github.com/mamoe")
// licenseFromGitHubProject("AGPLv3", "dev")
// publishPlatformArtifactsInRootModule = "jvm"
//}