mirai/mirai-core-api/build.gradle.kts

114 lines
3.3 KiB
Plaintext
Raw Normal View History

2020-11-01 15:07:32 +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-12-23 19:31:13 +08:00
@file:Suppress("UNUSED_VARIABLE")
2020-12-18 15:37:13 +08:00
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
2019-12-23 19:31:13 +08:00
plugins {
kotlin("multiplatform")
2020-03-24 10:01:03 +08:00
kotlin("plugin.serialization")
2021-01-21 10:08:21 +08:00
2021-02-25 09:35:51 +08:00
//id("kotlinx-atomicfu")
id("signing")
id("me.him188.kotlin-jvm-blocking-bridge")
2021-01-21 10:08:21 +08:00
2019-12-23 19:31:13 +08:00
`maven-publish`
}
description = "Mirai API module"
2019-12-23 19:31:13 +08:00
kotlin {
explicitApi()
2020-01-05 17:38:46 +08:00
if (isAndroidSDKAvailable) {
2021-02-01 12:23:04 +08:00
jvm("android") {
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.androidJvm)
2019-12-23 19:31:13 +08:00
}
} else {
2021-01-21 10:08:21 +08:00
printAndroidNotInstalled()
2019-12-23 19:31:13 +08:00
}
jvm("common") {
2020-12-18 15:37:13 +08:00
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.common)
2019-12-23 19:31:13 +08:00
}
2020-12-18 15:37:13 +08:00
jvm("jvm")
2020-10-03 13:35:05 +08:00
sourceSets {
2021-02-01 12:23:04 +08:00
val commonMain by getting {
2019-12-23 19:31:13 +08:00
dependencies {
api(kotlin("reflect"))
api(`kotlinx-serialization-core-jvm`)
api(`kotlinx-serialization-json-jvm`)
api(`kotlinx-coroutines-core-jvm`) // don't remove it, otherwise IDE will complain
api(`kotlinx-coroutines-jdk8`)
2021-01-21 10:08:21 +08:00
api(`ktor-client-okhttp`)
implementation(project(":mirai-core-utils"))
implementation(project(":mirai-console-compiler-annotations"))
implementation(`kotlinx-serialization-protobuf-jvm`)
implementation(`jetbrains-annotations`)
implementation(`log4j-api`)
implementation(`kotlinx-atomicfu-jvm`)
implementationKotlinxIoJvm()
2021-01-21 10:08:21 +08:00
compileOnly(`slf4j-api`)
2019-12-23 19:31:13 +08:00
}
}
commonTest {
dependencies {
runtimeOnly(`log4j-core`)
}
}
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`)
// api(`ktor-client-android`)
2020-01-05 18:16:11 +08:00
}
2019-12-23 19:31:13 +08:00
}
}
2021-02-01 12:23:04 +08:00
val jvmMain by getting {
2019-12-23 19:31:13 +08:00
2021-02-01 12:23:04 +08:00
}
val jvmTest by getting {
2019-12-23 19:31:13 +08:00
dependencies {
runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
2019-12-23 19:31:13 +08:00
}
}
}
2020-02-16 13:54:42 +08:00
}
2020-02-18 13:03:51 +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
}
tasks.getByName("androidTest").dependsOn("checkAndroidApiLevel")
2021-02-25 00:12:58 +08:00
}
2020-10-03 13:35:05 +08:00
2021-01-21 14:16:03 +08:00
configureMppPublishing()
afterEvaluate {
project(":binary-compatibility-validator").tasks["apiBuild"].dependsOn(project(":mirai-core-api").tasks["build"])
project(":binary-compatibility-validator-android").tasks["apiBuild"].dependsOn(project(":mirai-core-api").tasks["build"])
2021-01-21 14:16:03 +08:00
}