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

124 lines
3.9 KiB
Plaintext
Raw Normal View History

2020-12-02 09:25:25 +08:00
/*
2021-01-21 10:08:21 +08:00
* Copyright 2019-2021 Mamoe Technologies and contributors.
2020-12-02 09:25:25 +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
*/
@file:Suppress("UNUSED_VARIABLE")
2020-12-18 15:37:13 +08:00
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
2020-12-02 09:25:25 +08:00
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
2021-01-21 10:08:21 +08:00
2021-02-25 09:35:51 +08:00
//id("kotlinx-atomicfu")
2020-12-02 09:25:25 +08:00
id("net.mamoe.kotlin-jvm-blocking-bridge")
`maven-publish`
id("com.jfrog.bintray")
}
2021-01-21 10:08:21 +08:00
description = "mirai-core utilities"
2020-12-02 09:25:25 +08:00
kotlin {
explicitApi()
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()
2020-12-02 09:25:25 +08:00
}
} else {
2021-02-01 12:23:04 +08:00
printAndroidNotInstalled()
2020-12-02 09:25:25 +08:00
}
jvm("common") {
2020-12-18 15:37:13 +08:00
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.common)
2020-12-02 09:25:25 +08:00
}
2020-12-18 15:37:13 +08:00
jvm("jvm")
2020-12-02 09:25:25 +08:00
// jvm("android") {
// attributes.attribute(Attribute.of("mirai.target.platform", String::class.java), "android")
// }
sourceSets {
val commonMain by getting {
dependencies {
api(kotlin("reflect"))
api1(`kotlinx-serialization-core`)
api1(`kotlinx-serialization-json`)
implementation1(`kotlinx-serialization-protobuf`)
api1(`kotlinx-io-jvm`)
api1(`kotlinx-coroutines-io-jvm`)
api(`kotlinx-coroutines-core`)
implementation1(`kotlinx-atomicfu`)
api1(`ktor-client-core`)
api1(`ktor-network`)
}
}
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`)
2020-12-02 09:25:25 +08:00
api1(`ktor-client-android`)
}
}
}
val jvmMain by getting
val jvmTest by getting {
dependencies {
runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
}
}
}
}
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")
}
2021-01-21 10:08:21 +08:00
configureMppPublishing()