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

125 lines
3.8 KiB
Plaintext
Raw Normal View History

2020-12-02 09:25:25 +08:00
/*
2022-05-17 16:43:09 +08:00
* Copyright 2019-2022 Mamoe Technologies and contributors.
2020-12-02 09:25:25 +08:00
*
2022-05-17 16:43:09 +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-12-02 09:25:25 +08:00
*
2022-05-17 16:43:09 +08:00
* https://github.com/mamoe/mirai/blob/dev/LICENSE
2020-12-02 09:25:25 +08:00
*/
@file:Suppress("UNUSED_VARIABLE")
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
2021-01-21 10:08:21 +08:00
2021-04-14 12:51:44 +08:00
id("kotlinx-atomicfu")
id("me.him188.kotlin-jvm-blocking-bridge")
2020-12-02 09:25:25 +08:00
`maven-publish`
}
2021-01-21 10:08:21 +08:00
description = "mirai-core utilities"
2020-12-02 09:25:25 +08:00
kotlin {
explicitApi()
2022-05-19 03:54:47 +08:00
configureHMPP()
2022-05-29 06:03:13 +08:00
configureNativeTargetsHierarchical(project)
2020-12-02 09:25:25 +08:00
sourceSets {
val commonMain by getting {
dependencies {
api(kotlin("reflect"))
2022-05-17 16:43:09 +08:00
api(`kotlinx-serialization-core`)
api(`kotlinx-serialization-json`)
api(`kotlinx-coroutines-core`)
2020-12-02 09:25:25 +08:00
2022-05-17 16:43:09 +08:00
implementation(`kotlinx-atomicfu`)
implementation(`kotlinx-serialization-protobuf`)
2022-05-19 01:46:38 +08:00
implementation(`ktor-io`)
2020-12-02 09:25:25 +08:00
}
}
val commonTest by getting {
dependencies {
2022-05-17 16:43:09 +08:00
api(yamlkt)
}
}
val jvmBaseMain by getting {
dependencies {
2022-05-19 03:54:47 +08:00
implementation(`jetbrains-annotations`)
}
}
2020-12-02 09:25:25 +08:00
if (isAndroidSDKAvailable) {
2021-02-01 12:23:04 +08:00
val androidMain by getting {
//
2020-12-02 09:25:25 +08:00
dependencies {
2021-02-01 12:23:04 +08:00
compileOnly(`android-runtime`)
// api1(`ktor-client-android`)
2020-12-02 09:25:25 +08:00
}
}
}
val jvmMain by getting
val jvmTest by getting {
dependencies {
runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
}
}
2022-05-17 16:43:09 +08:00
val nativeMain by getting {
dependencies {
2022-05-19 03:54:47 +08:00
// implementation("com.soywiz.korlibs.krypto:krypto:2.4.12") // ':mirai-core-utils:compileNativeMainKotlinMetadata' fails because compiler cannot find reference
}
}
val mingwMain by getting {
dependencies {
}
}
val unixMain by getting {
dependencies {
2022-05-17 16:43:09 +08:00
}
}
2020-12-02 09:25:25 +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-12-02 09:25:25 +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")
}
configureMppPublishing()