| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- /*
- * 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("UNUSED_VARIABLE")
- import BinaryCompatibilityConfigurator.configureBinaryValidators
- import shadow.relocateCompileOnly
- import shadow.relocateImplementation
- plugins {
- kotlin("multiplatform")
- id("kotlinx-atomicfu")
- kotlin("plugin.serialization")
- id("me.him188.kotlin-jvm-blocking-bridge")
- id("me.him188.kotlin-dynamic-delegation")
- // id("me.him188.maven-central-publish")
- `maven-publish`
- }
- description = "Mirai Protocol implementation for QQ Android"
- kotlin {
- explicitApi()
- apply(plugin = "explicit-api")
- configureJvmTargetsHierarchical("net.mamoe.mirai.internal")
- optInForAllSourceSets("net.mamoe.mirai.utils.MiraiExperimentalApi")
- optInForAllSourceSets("net.mamoe.mirai.utils.MiraiInternalApi")
- optInForAllSourceSets("net.mamoe.mirai.LowLevelApi")
- optInForAllSourceSets("kotlinx.serialization.ExperimentalSerializationApi")
- sourceSets.apply {
- val commonMain by getting {
- dependencies {
- api(project(":mirai-core-api"))
- api(`kotlinx-serialization-core`)
- api(`kotlinx-serialization-json`)
- api(`kotlinx-coroutines-core`)
- implementation(`kt-bignum`)
- implementation(project(":mirai-core-utils"))
- implementation(`kotlinx-serialization-protobuf`)
- implementation(`kotlinx-atomicfu`)
- // runtime from mirai-core-utils
- relocateCompileOnly(`ktor-io_relocated`)
- // relocateImplementation(`ktor-http_relocated`)
- // relocateImplementation(`ktor-serialization_relocated`)
- // relocateImplementation(`ktor-websocket-serialization_relocated`)
- }
- }
- commonTest {
- dependencies {
- implementation(kotlin("script-runtime"))
- implementation(`kotlinx-coroutines-test`)
- api(yamlkt)
- }
- }
- findByName("jvmBaseMain")?.apply {
- dependencies {
- implementation(`log4j-api`)
- implementation(`netty-handler`)
- api(`kotlinx-coroutines-jdk8`) // use -jvm modules for this magic target 'jvmBase'
- }
- }
- findByName("jvmBaseTest")?.apply {
- 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)
- }
- }
- // For Android with SDK
- findByName("androidUnitTest")?.apply {
- dependencies {
- implementation(bouncycastle)
- }
- }
- findByName("jvmMain")?.apply {
- dependencies {
- implementation(bouncycastle)
- // api(kotlinx("coroutines-debug", Versions.coroutines))
- }
- }
- findByName("jvmTest")?.apply {
- dependencies {
- api(`kotlinx-coroutines-debug`)
- // implementation("net.mamoe:mirai-login-solver-selenium:1.0-dev-14")
- }
- }
- // Kt bignum
- findByName("jvmBaseMain")?.apply {
- dependencies {
- relocateImplementation(`kt-bignum_relocated`)
- }
- }
- // Ktor
- findByName("commonMain")?.apply {
- dependencies {
- compileOnly(`ktor-io`)
- implementation(`ktor-client-core`)
- }
- }
- findByName("jvmBaseMain")?.apply {
- // relocate for JVM like modules
- dependencies {
- relocateCompileOnly(`ktor-io_relocated`) // runtime from mirai-core-utils
- relocateImplementation(`ktor-client-core_relocated`)
- }
- }
- findByName("jvmBaseMain")?.apply {
- dependencies {
- relocateImplementation(`ktor-client-okhttp_relocated`)
- }
- }
- }
- }
- 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")
- }
- tasks.findByName("androidTest")?.dependsOn("checkAndroidApiLevel")
- }
- configureMppPublishing()
- configureBinaryValidators(setOf("jvm", "android").filterTargets())
- //mavenCentralPublish {
- // artifactId = "mirai-core"
- // githubProject("mamoe", "mirai")
- // developer("Mamoe Technologies", email = "[email protected]", url = "https://github.com/mamoe")
- // licenseFromGitHubProject("AGPLv3", "dev")
- // publishPlatformArtifactsInRootModule = "jvm"
- //}
|