mirai/mirai-core/build.gradle.kts

157 lines
5.5 KiB
Plaintext
Raw Normal View History

2019-11-15 10:39:00 +08:00
@file:Suppress("UNUSED_VARIABLE")
2019-10-30 23:00:29 +08:00
plugins {
kotlin("multiplatform")
2019-12-06 23:50:54 +08:00
id("kotlinx-atomicfu")
2019-11-17 12:52:48 +08:00
id("kotlinx-serialization")
2019-11-15 10:39:00 +08:00
`maven-publish`
2020-02-15 22:54:17 +08:00
id("com.jfrog.bintray") version "1.8.4-jetbrains-3"
2019-10-30 23:00:29 +08:00
}
2019-11-17 12:52:48 +08:00
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
2019-12-02 17:57:14 +08:00
fun kotlinx(id: String, version: String) = "org.jetbrains.kotlinx:kotlinx-$id:$version"
2019-10-30 23:00:29 +08:00
2019-12-02 17:57:14 +08:00
fun ktor(id: String, version: String) = "io.ktor:ktor-$id:$version"
2019-11-23 22:34:57 +08:00
2019-12-02 23:04:58 +08:00
description = "QQ protocol library"
2019-10-30 23:00:29 +08:00
2020-01-05 18:16:11 +08:00
val isAndroidSDKAvailable: Boolean by project
2019-11-06 21:22:23 +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"))
android("android") {
publishAllLibraryVariants()
2019-10-30 23:00:29 +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.
""".trimIndent()
)
2019-10-30 23:00:29 +08:00
}
2019-11-23 22:34:57 +08:00
jvm("jvm") {
2019-11-06 21:22:23 +08:00
}
2019-10-30 23:00:29 +08:00
2019-11-23 22:34:57 +08:00
sourceSets {
all {
languageSettings.enableLanguageFeature("InlineClasses")
2019-11-23 22:34:57 +08:00
languageSettings.useExperimentalAnnotation("kotlin.Experimental")
2019-11-08 20:51:40 +08:00
2019-11-23 22:34:57 +08:00
dependencies {
2020-02-13 13:18:51 +08:00
api(kotlin("stdlib", kotlinVersion))
api(kotlin("serialization", kotlinVersion))
2019-10-30 23:00:29 +08:00
2020-02-13 13:18:51 +08:00
api("org.jetbrains.kotlinx:atomicfu:$atomicFuVersion")
api(kotlinx("io", kotlinXIoVersion))
api(kotlinx("coroutines-io", coroutinesIoVersion))
api(kotlinx("coroutines-core", coroutinesVersion))
2019-11-23 22:34:57 +08:00
}
2019-10-30 23:00:29 +08:00
}
2019-11-23 22:34:57 +08:00
commonMain {
dependencies {
api(kotlin("reflect", kotlinVersion))
api(kotlin("serialization", kotlinVersion))
2019-12-02 17:57:14 +08:00
api(kotlinx("coroutines-core-common", coroutinesVersion))
api(kotlinx("serialization-runtime-common", serializationVersion))
2019-11-23 22:34:57 +08:00
2019-12-02 17:57:14 +08:00
api(ktor("http-cio", ktorVersion))
api(ktor("http", ktorVersion))
api(ktor("client-core-jvm", ktorVersion))
api(ktor("client-cio", ktorVersion))
api(ktor("client-core", ktorVersion))
api(ktor("network", ktorVersion))
2019-11-23 22:34:57 +08:00
//implementation("io.ktor:ktor-io:1.3.0-beta-1")
2019-12-06 23:50:54 +08:00
2020-02-07 18:43:24 +08:00
//runtimeOnly(files("build/classes/kotlin/metadata/main")) // classpath is not properly set by IDE
2019-11-23 22:34:57 +08:00
}
2019-11-22 19:10:10 +08:00
}
2019-11-23 22:34:57 +08:00
commonTest {
dependencies {
2020-02-12 13:52:07 +08:00
implementation(kotlin("test-annotations-common"))
implementation(kotlin("test-common"))
2019-12-06 23:50:54 +08:00
2020-02-07 18:43:24 +08:00
//runtimeOnly(files("build/classes/kotlin/metadata/test")) // classpath is not properly set by IDE
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) {
val androidMain by getting {
dependencies {
api(kotlin("reflect", kotlinVersion))
2019-10-30 23:00:29 +08:00
2020-02-12 13:52:07 +08:00
api(kotlinx("io", kotlinXIoVersion))
api(kotlinx("io-jvm", kotlinXIoVersion))
2020-01-05 18:16:11 +08:00
api(kotlinx("serialization-runtime", serializationVersion))
api(kotlinx("coroutines-android", coroutinesVersion))
2019-11-17 12:52:48 +08:00
2020-01-05 18:16:11 +08:00
api(ktor("client-android", ktorVersion))
}
2019-11-23 22:34:57 +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-07 00:17:34 +08:00
}
}
2019-11-23 22:34:57 +08:00
val jvmMain by getting {
2019-11-15 10:39:00 +08:00
dependencies {
2019-12-05 20:12:44 +08:00
//api(kotlin("stdlib-jdk8", kotlinVersion))
//api(kotlin("stdlib-jdk7", kotlinVersion))
2019-11-23 22:34:57 +08:00
api(kotlin("reflect", kotlinVersion))
2019-12-02 17:57:14 +08:00
api(ktor("client-core-jvm", ktorVersion))
api(kotlinx("io-jvm", kotlinXIoVersion))
api(kotlinx("serialization-runtime", serializationVersion))
2020-02-12 13:52:07 +08:00
api(kotlinx("coroutines-io", coroutinesIoVersion))
api(kotlinx("coroutines-io-jvm", coroutinesIoVersion))
api(kotlinx("io-jvm", coroutinesIoVersion))
2019-12-06 23:50:54 +08:00
2020-01-06 20:49:26 +08:00
api("org.bouncycastle:bcprov-jdk15on:1.64")
2019-12-06 23:50:54 +08:00
runtimeOnly(files("build/classes/kotlin/jvm/main")) // classpath is not properly set by IDE
2019-11-15 10:39:00 +08:00
}
}
2019-11-23 22:34:57 +08:00
val jvmTest by getting {
dependencies {
2020-02-12 13:52:07 +08:00
implementation(kotlin("test", kotlinVersion))
implementation(kotlin("test-junit", kotlinVersion))
2019-12-06 23:50:54 +08:00
implementation("org.pcap4j:pcap4j-distribution:1.8.2")
runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
2019-11-15 10:39:00 +08:00
}
}
}
2020-02-16 13:54:42 +08:00
}
2020-02-18 13:18:30 +08:00
//
//tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
// kotlinOptions.jvmTarget = "1.8"
//}
2020-02-18 13:03:51 +08:00
2020-02-16 13:54:42 +08:00
apply(from = rootProject.file("gradle/publish.gradle"))