2020-11-01 15:07:32 +08:00
|
|
|
/*
|
2021-01-15 00:45:53 +08:00
|
|
|
* Copyright 2019-2021 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.
|
|
|
|
*
|
|
|
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
|
|
|
*/
|
|
|
|
|
2019-11-15 10:39:00 +08:00
|
|
|
@file:Suppress("UNUSED_VARIABLE")
|
|
|
|
|
2020-12-18 15:37:13 +08:00
|
|
|
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
2020-10-03 13:35:05 +08:00
|
|
|
|
2019-10-30 23:00:29 +08:00
|
|
|
plugins {
|
|
|
|
kotlin("multiplatform")
|
2020-10-03 13:47:36 +08:00
|
|
|
// id("kotlinx-atomicfu")
|
2020-03-24 10:01:03 +08:00
|
|
|
kotlin("plugin.serialization")
|
2020-08-18 22:09:05 +08:00
|
|
|
id("net.mamoe.kotlin-jvm-blocking-bridge")
|
2019-11-15 10:39:00 +08:00
|
|
|
`maven-publish`
|
2019-10-30 23:00:29 +08:00
|
|
|
}
|
|
|
|
|
2020-10-03 12:42:13 +08:00
|
|
|
description = "Mirai Protocol implementation for QQ Android"
|
2019-10-30 23:00:29 +08:00
|
|
|
|
2020-11-22 14:25:49 +08:00
|
|
|
afterEvaluate {
|
|
|
|
tasks.getByName("compileKotlinCommon").enabled = false
|
|
|
|
tasks.getByName("compileTestKotlinCommon").enabled = false
|
2020-11-22 14:45:03 +08:00
|
|
|
|
|
|
|
tasks.getByName("compileCommonMainKotlinMetadata").enabled = false
|
|
|
|
tasks.getByName("compileKotlinMetadata").enabled = false
|
2020-11-22 14:25:49 +08:00
|
|
|
}
|
|
|
|
|
2019-11-06 21:22:23 +08:00
|
|
|
kotlin {
|
2021-01-22 11:19:11 +08:00
|
|
|
explicitApi()
|
|
|
|
|
2020-01-05 17:38:46 +08:00
|
|
|
if (isAndroidSDKAvailable) {
|
2021-02-01 12:23:04 +08:00
|
|
|
// apply(from = rootProject.file("gradle/android.gradle"))
|
|
|
|
// android("android") {
|
|
|
|
// publishAllLibraryVariants()
|
|
|
|
// }
|
|
|
|
jvm("android") {
|
|
|
|
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.androidJvm)
|
|
|
|
// publishAllLibraryVariants()
|
2019-10-30 23:00:29 +08:00
|
|
|
}
|
2020-01-05 17:18:02 +08:00
|
|
|
} else {
|
2021-01-21 10:08:21 +08:00
|
|
|
printAndroidNotInstalled()
|
2019-10-30 23:00:29 +08:00
|
|
|
}
|
|
|
|
|
2020-11-22 14:25:49 +08:00
|
|
|
jvm("common") {
|
2020-12-18 15:37:13 +08:00
|
|
|
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.common)
|
2020-11-22 14:25:49 +08:00
|
|
|
}
|
|
|
|
|
2020-12-18 15:37:13 +08:00
|
|
|
jvm("jvm")
|
2019-10-30 23:00:29 +08:00
|
|
|
|
2020-11-22 14:25:49 +08:00
|
|
|
/*
|
|
|
|
jvm("android") {
|
|
|
|
attributes.attribute(ATTRIBUTE_MIRAI_TARGET_PLATFORM, "android")
|
|
|
|
}*/
|
|
|
|
|
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 {
|
2021-01-30 19:13:03 +08:00
|
|
|
api(project(":mirai-core-api"))
|
2020-12-02 09:25:25 +08:00
|
|
|
implementation(project(":mirai-core-utils"))
|
2020-10-03 13:35:05 +08:00
|
|
|
api1(`kotlinx-serialization-core`)
|
2020-11-22 14:25:49 +08:00
|
|
|
api1(`kotlinx-serialization-json`)
|
2020-10-03 13:35:05 +08:00
|
|
|
implementation1(`kotlinx-serialization-protobuf`)
|
|
|
|
|
|
|
|
api1(`kotlinx-atomicfu`)
|
|
|
|
api1(`kotlinx-coroutines-core`)
|
|
|
|
|
2021-01-30 19:13:03 +08:00
|
|
|
api1(`kotlinx-io-jvm`)
|
2020-10-03 13:35:05 +08:00
|
|
|
implementation1(`kotlinx-coroutines-io`)
|
2021-04-13 00:23:27 +08:00
|
|
|
implementation(`netty-all`)
|
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 {
|
2020-10-03 12:42:13 +08:00
|
|
|
implementation(kotlin("script-runtime"))
|
2021-04-17 16:05:05 +08:00
|
|
|
runtimeOnly(`slf4j-simple`)
|
2019-11-23 22:34:57 +08:00
|
|
|
}
|
2019-11-13 19:49:21 +08:00
|
|
|
}
|
2019-10-31 23:11:55 +08:00
|
|
|
|
2020-01-05 18:16:11 +08:00
|
|
|
if (isAndroidSDKAvailable) {
|
2021-02-01 12:23:04 +08:00
|
|
|
val androidMain by getting {
|
|
|
|
dependsOn(commonMain)
|
2020-01-05 18:16:11 +08:00
|
|
|
dependencies {
|
2021-02-01 12:23:04 +08:00
|
|
|
compileOnly(`android-runtime`)
|
2020-01-05 18:16:11 +08:00
|
|
|
}
|
2019-11-23 22:34:57 +08:00
|
|
|
}
|
2021-02-01 12:23:04 +08:00
|
|
|
val androidTest by getting {
|
2020-01-05 18:16:11 +08:00
|
|
|
dependencies {
|
2020-10-03 13:35:05 +08:00
|
|
|
implementation(kotlin("test", Versions.kotlinCompiler))
|
2021-04-15 22:32:07 +08:00
|
|
|
implementation(kotlin("test-junit5", Versions.kotlinCompiler))
|
2020-02-12 13:52:07 +08:00
|
|
|
implementation(kotlin("test-annotations-common"))
|
|
|
|
implementation(kotlin("test-common"))
|
2021-04-20 18:02:50 +08:00
|
|
|
implementation("org.bouncycastle:bcprov-jdk15on:1.64")
|
2020-01-05 18:16:11 +08:00
|
|
|
}
|
2019-12-07 00:17:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-01 12:23:04 +08:00
|
|
|
val jvmMain by getting {
|
2019-11-15 10:39:00 +08:00
|
|
|
dependencies {
|
2020-10-03 12:42:13 +08:00
|
|
|
implementation("org.bouncycastle:bcprov-jdk15on:1.64")
|
2020-10-03 13:35:05 +08:00
|
|
|
// api(kotlinx("coroutines-debug", Versions.coroutines))
|
2019-11-15 10:39:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-01 12:23:04 +08:00
|
|
|
val jvmTest by getting {
|
2019-11-23 22:34:57 +08:00
|
|
|
dependencies {
|
2021-06-08 12:25:08 +08:00
|
|
|
api1(`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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-16 13:54:42 +08:00
|
|
|
}
|
2020-03-24 10:01:03 +08:00
|
|
|
|
2021-04-05 22:35:38 +08:00
|
|
|
if (isAndroidSDKAvailable) {
|
|
|
|
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
|
|
|
}
|
2021-04-05 22:35:38 +08:00
|
|
|
tasks.getByName("androidTest").dependsOn("checkAndroidApiLevel")
|
2021-02-25 00:12:58 +08:00
|
|
|
}
|
|
|
|
|
2020-08-22 12:56:41 +08:00
|
|
|
fun org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler.implementation1(dependencyNotation: String) =
|
|
|
|
implementation(dependencyNotation) {
|
|
|
|
exclude("org.jetbrains.kotlin", "kotlin-stdlib")
|
|
|
|
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core")
|
|
|
|
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core-common")
|
|
|
|
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core-jvm")
|
|
|
|
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core-metadata")
|
|
|
|
}
|
|
|
|
|
|
|
|
fun org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler.api1(dependencyNotation: String) =
|
|
|
|
api(dependencyNotation) {
|
|
|
|
exclude("org.jetbrains.kotlin", "kotlin-stdlib")
|
|
|
|
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core")
|
|
|
|
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core-common")
|
|
|
|
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core-jvm")
|
|
|
|
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core-metadata")
|
|
|
|
}
|
|
|
|
|
2021-01-21 10:08:21 +08:00
|
|
|
configureMppPublishing()
|