2019-12-23 19:31:13 +08:00
|
|
|
@file:Suppress("UNUSED_VARIABLE")
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
kotlin("multiplatform")
|
|
|
|
id("kotlinx-atomicfu")
|
2020-03-24 10:01:03 +08:00
|
|
|
kotlin("plugin.serialization")
|
2019-12-23 19:31:13 +08:00
|
|
|
`maven-publish`
|
2020-03-24 17:32:22 +08:00
|
|
|
id("com.jfrog.bintray") version Versions.Publishing.bintray
|
2019-12-23 19:31:13 +08:00
|
|
|
}
|
|
|
|
|
2020-04-16 10:39:27 +08:00
|
|
|
description = "Mirai Protocol implementation for QQ Android"
|
2019-12-23 19:31:13 +08:00
|
|
|
|
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") {
|
|
|
|
}
|
|
|
|
|
2020-07-20 15:06:30 +08:00
|
|
|
sourceSets.apply {
|
2019-12-23 19:31:13 +08:00
|
|
|
all {
|
|
|
|
languageSettings.enableLanguageFeature("InlineClasses")
|
|
|
|
languageSettings.useExperimentalAnnotation("kotlin.Experimental")
|
2020-05-10 02:22:16 +08:00
|
|
|
languageSettings.useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiInternalAPI")
|
|
|
|
languageSettings.useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiExperimentalAPI")
|
|
|
|
languageSettings.useExperimentalAnnotation("net.mamoe.mirai.LowLevelAPI")
|
|
|
|
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
|
|
|
languageSettings.useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
|
|
|
|
languageSettings.useExperimentalAnnotation("kotlin.time.ExperimentalTime")
|
|
|
|
languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
|
2020-08-18 08:50:16 +08:00
|
|
|
languageSettings.useExperimentalAnnotation("kotlinx.serialization.ExperimentalSerializationApi")
|
2020-08-18 21:21:21 +08:00
|
|
|
languageSettings.useExperimentalAnnotation("net.mamoe.mirai.utils.UnstableExternalImage")
|
2020-07-20 15:06:30 +08:00
|
|
|
|
2020-05-09 22:23:02 +08:00
|
|
|
languageSettings.progressiveMode = true
|
2019-12-23 19:31:13 +08:00
|
|
|
|
|
|
|
dependencies {
|
|
|
|
api(project(":mirai-core"))
|
|
|
|
}
|
|
|
|
}
|
2020-03-24 10:01:03 +08:00
|
|
|
|
2020-04-15 18:18:59 +08:00
|
|
|
val commonMain by getting {
|
2019-12-23 19:31:13 +08:00
|
|
|
dependencies {
|
2020-08-18 08:50:16 +08:00
|
|
|
api(kotlinx("serialization-core", Versions.Kotlin.serialization))
|
2020-07-31 16:29:25 +08:00
|
|
|
implementation(kotlinx("serialization-protobuf", Versions.Kotlin.serialization))
|
2020-03-24 10:01:03 +08:00
|
|
|
api("org.jetbrains.kotlinx:atomicfu:${Versions.Kotlin.atomicFU}")
|
2020-07-31 16:29:25 +08:00
|
|
|
implementation(kotlinx("io", Versions.Kotlin.io))
|
|
|
|
implementation(kotlinx("coroutines-io", Versions.Kotlin.coroutinesIo))
|
2019-12-23 19:31:13 +08:00
|
|
|
}
|
|
|
|
}
|
2020-03-24 10:01:03 +08:00
|
|
|
|
2020-04-15 18:18:59 +08:00
|
|
|
val commonTest by getting {
|
2019-12-23 19:31:13 +08:00
|
|
|
dependencies {
|
2020-03-24 10:01:03 +08:00
|
|
|
implementation(kotlin("test-annotations-common"))
|
|
|
|
implementation(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-07-20 15:06:30 +08:00
|
|
|
implementation(kotlin("test", Versions.Kotlin.compiler))
|
|
|
|
implementation(kotlin("test-junit", Versions.Kotlin.compiler))
|
2020-02-12 13:52:07 +08:00
|
|
|
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-07-31 16:29:25 +08:00
|
|
|
implementation("org.bouncycastle:bcprov-jdk15on:1.64")
|
2020-08-18 08:50:16 +08:00
|
|
|
implementation(kotlinx("io-jvm", Versions.Kotlin.io))
|
2020-06-01 20:38:31 +08:00
|
|
|
// api(kotlinx("coroutines-debug", Versions.Kotlin.coroutines))
|
2019-12-23 19:31:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
val jvmTest by getting {
|
|
|
|
dependencies {
|
2020-04-15 18:18:59 +08:00
|
|
|
dependsOn(commonTest)
|
2020-07-20 15:06:30 +08:00
|
|
|
implementation(kotlin("test", Versions.Kotlin.compiler))
|
|
|
|
implementation(kotlin("test-junit", Versions.Kotlin.compiler))
|
2019-12-23 19:31:13 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-16 13:54:42 +08:00
|
|
|
}
|
2020-02-18 13:03:51 +08:00
|
|
|
|
2020-02-16 13:54:42 +08:00
|
|
|
apply(from = rootProject.file("gradle/publish.gradle"))
|
2020-08-18 09:24:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
tasks.withType<com.jfrog.bintray.gradle.tasks.BintrayUploadTask> {
|
|
|
|
doFirst {
|
|
|
|
publishing.publications
|
|
|
|
.filterIsInstance<MavenPublication>()
|
|
|
|
.forEach { publication ->
|
|
|
|
val moduleFile = buildDir.resolve("publications/${publication.name}/module.json")
|
|
|
|
if (moduleFile.exists()) {
|
|
|
|
publication.artifact(object : org.gradle.api.publish.maven.internal.artifact.FileBasedMavenArtifact(moduleFile) {
|
|
|
|
override fun getDefaultExtension() = "module"
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|