2019-12-23 19:31:13 +08:00
|
|
|
@file:Suppress("UNUSED_VARIABLE")
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
kotlin("multiplatform")
|
|
|
|
id("kotlinx-atomicfu")
|
|
|
|
id("kotlinx-serialization")
|
|
|
|
`maven-publish`
|
|
|
|
id("com.jfrog.bintray") version "1.8.4-jetbrains-3" // DO NOT CHANGE THIS VERSION UNLESS YOU WANT TO WASTE YOUR TIME
|
|
|
|
}
|
|
|
|
|
|
|
|
apply(from = rootProject.file("gradle/publish.gradle"))
|
|
|
|
|
|
|
|
val kotlinVersion: String by rootProject.ext
|
|
|
|
val atomicFuVersion: String by rootProject.ext
|
|
|
|
val coroutinesVersion: String by rootProject.ext
|
|
|
|
val kotlinXIoVersion: String by rootProject.ext
|
|
|
|
val coroutinesIoVersion: String by rootProject.ext
|
|
|
|
|
|
|
|
val klockVersion: String by rootProject.ext
|
|
|
|
val ktorVersion: String by rootProject.ext
|
|
|
|
|
|
|
|
val serializationVersion: String by rootProject.ext
|
|
|
|
|
|
|
|
fun kotlinx(id: String, version: String) = "org.jetbrains.kotlinx:kotlinx-$id:$version"
|
|
|
|
|
|
|
|
fun ktor(id: String, version: String) = "io.ktor:ktor-$id:$version"
|
|
|
|
|
|
|
|
|
|
|
|
description = "QQ protocol library"
|
|
|
|
version = rootProject.ext.get("mirai_version")!!.toString()
|
|
|
|
|
2020-01-05 18:16:11 +08:00
|
|
|
val isAndroidSDKAvailable: Boolean by project
|
|
|
|
|
2019-12-23 19:31:13 +08:00
|
|
|
kotlin {
|
2020-01-05 17:38:46 +08:00
|
|
|
if (isAndroidSDKAvailable) {
|
2020-01-21 14:49:42 +08:00
|
|
|
apply(from = rootProject.file("gradle/android.gradle"))
|
2020-01-05 17:18:02 +08:00
|
|
|
android("android") {
|
|
|
|
publishAllLibraryVariants()
|
2019-12-23 19:31:13 +08:00
|
|
|
}
|
2020-01-05 17:18:02 +08:00
|
|
|
} else {
|
|
|
|
println(
|
|
|
|
"""Android SDK 可能未安装.
|
|
|
|
$name 的 Android 目标编译将不会进行.
|
2020-01-05 17:38:46 +08:00
|
|
|
这不会影响 Android 以外的平台的编译.
|
|
|
|
""".trimIndent()
|
|
|
|
)
|
|
|
|
println(
|
|
|
|
"""Android SDK might not be installed.
|
|
|
|
Android target of $name will not be compiled.
|
|
|
|
It does no influence on the compilation of other platforms.
|
2020-01-05 17:18:02 +08:00
|
|
|
""".trimIndent()
|
|
|
|
)
|
2019-12-23 19:31:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
jvm("jvm") {
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
all {
|
|
|
|
languageSettings.enableLanguageFeature("InlineClasses")
|
2020-01-28 20:37:02 +08:00
|
|
|
|
2019-12-23 19:31:13 +08:00
|
|
|
languageSettings.useExperimentalAnnotation("kotlin.Experimental")
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
api(project(":mirai-core"))
|
|
|
|
|
|
|
|
api(kotlin("stdlib", kotlinVersion))
|
|
|
|
|
|
|
|
api("org.jetbrains.kotlinx:atomicfu:$atomicFuVersion")
|
|
|
|
api(kotlinx("io", kotlinXIoVersion))
|
|
|
|
api(kotlinx("coroutines-io", coroutinesIoVersion))
|
|
|
|
api(kotlinx("coroutines-core", coroutinesVersion))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
commonMain {
|
|
|
|
dependencies {
|
2020-01-27 21:00:33 +08:00
|
|
|
api(kotlinx("serialization-runtime-common", serializationVersion))
|
2019-12-23 19:31:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
commonTest {
|
|
|
|
dependencies {
|
|
|
|
api(kotlin("test-annotations-common"))
|
|
|
|
api(kotlin("test-common"))
|
2019-12-30 16:31:28 +08:00
|
|
|
implementation(kotlin("script-runtime"))
|
2019-12-23 19:31:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-05 18:16:11 +08:00
|
|
|
if (isAndroidSDKAvailable) {
|
|
|
|
val androidMain by getting {
|
|
|
|
dependencies {
|
|
|
|
}
|
2019-12-23 19:31:13 +08:00
|
|
|
}
|
|
|
|
|
2020-01-05 18:16:11 +08:00
|
|
|
val androidTest by getting {
|
|
|
|
dependencies {
|
2020-02-12 13:52:07 +08:00
|
|
|
implementation(kotlin("test", kotlinVersion))
|
|
|
|
implementation(kotlin("test-junit", kotlinVersion))
|
|
|
|
implementation(kotlin("test-annotations-common"))
|
|
|
|
implementation(kotlin("test-common"))
|
2020-01-05 18:16:11 +08:00
|
|
|
}
|
2019-12-23 19:31:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
val jvmMain by getting {
|
|
|
|
dependencies {
|
2020-02-07 10:11:47 +08:00
|
|
|
runtimeOnly(files("build/classes/kotlin/jvm/main")) // classpath is not properly set by IDE
|
2020-01-27 21:00:33 +08:00
|
|
|
api(kotlinx("serialization-runtime", serializationVersion))
|
2019-12-23 19:31:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
val jvmTest by getting {
|
|
|
|
dependencies {
|
|
|
|
api(kotlin("test", kotlinVersion))
|
|
|
|
api(kotlin("test-junit", kotlinVersion))
|
|
|
|
implementation("org.pcap4j:pcap4j-distribution:1.8.2")
|
|
|
|
|
2020-02-07 10:11:47 +08:00
|
|
|
runtimeOnly(files("build/classes/kotlin/jvm/main")) // classpath is not properly set by IDE
|
|
|
|
runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
|
2019-12-23 19:31:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|