mirai/mirai-core/build.gradle.kts

165 lines
5.9 KiB
Plaintext
Raw Normal View History

2019-11-15 10:39:00 +08:00
@file:Suppress("UNUSED_VARIABLE")
2020-10-03 13:35:05 +08:00
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
2019-10-30 23:00:29 +08:00
plugins {
kotlin("multiplatform")
2020-10-03 13:47:36 +08:00
// id("kotlinx-atomicfu")
2020-03-24 10:01:03 +08:00
kotlin("plugin.serialization")
2020-08-18 22:09:05 +08:00
id("net.mamoe.kotlin-jvm-blocking-bridge")
2019-11-15 10:39:00 +08:00
`maven-publish`
2020-09-22 18:56:27 +08:00
id("com.jfrog.bintray")
java
2019-10-30 23:00:29 +08:00
}
description = "Mirai Protocol implementation for QQ Android"
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
}
jvm("jvm") {
withJava()
}
2019-10-30 23:00:29 +08:00
2020-07-20 15:06:30 +08:00
sourceSets.apply {
2019-11-23 22:34:57 +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 09:24:44 +08:00
languageSettings.useExperimentalAnnotation("kotlinx.serialization.ExperimentalSerializationApi")
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
dependencies {
api(project(":mirai-core-api"))
}
2020-03-07 22:23:10 +08:00
}
2019-11-08 20:51:40 +08:00
2020-10-03 13:35:05 +08:00
commonMain {
2019-11-23 22:34:57 +08:00
dependencies {
2020-10-03 13:35:05 +08:00
api1(`kotlinx-serialization-core`)
implementation1(`kotlinx-serialization-protobuf`)
api1(`kotlinx-atomicfu`)
api1(`kotlinx-coroutines-core`)
api1(`kotlinx-io`)
implementation1(`kotlinx-coroutines-io`)
2019-11-23 22:34:57 +08:00
}
2019-11-22 19:10:10 +08:00
}
2020-07-20 17:21:00 +08:00
2020-10-03 13:35:05 +08:00
commonTest {
2019-11-23 22:34:57 +08:00
dependencies {
implementation(kotlin("script-runtime"))
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) {
2020-10-03 13:35:05 +08:00
androidMain {
2020-01-05 18:16:11 +08:00
dependencies {
}
2019-11-23 22:34:57 +08:00
}
2020-10-03 13:35:05 +08:00
androidTest {
2020-01-05 18:16:11 +08:00
dependencies {
2020-10-03 13:35:05 +08:00
implementation(kotlin("test", Versions.kotlinCompiler))
implementation(kotlin("test-junit", Versions.kotlinCompiler))
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-07 00:17:34 +08:00
}
}
2020-10-03 13:35:05 +08:00
jvmMain {
2019-11-15 10:39:00 +08:00
dependencies {
implementation("org.bouncycastle:bcprov-jdk15on:1.64")
2020-10-03 13:35:05 +08:00
api1(`kotlinx-io-jvm`)
// api(kotlinx("coroutines-debug", Versions.coroutines))
2019-11-15 10:39:00 +08:00
}
}
2020-10-03 13:35:05 +08:00
jvmTest {
2019-11-23 22:34:57 +08:00
dependencies {
2019-12-06 23:50:54 +08:00
implementation("org.pcap4j:pcap4j-distribution:1.8.2")
2019-11-15 10:39:00 +08:00
}
}
}
2020-02-16 13:54:42 +08:00
}
2020-03-24 10:01:03 +08:00
2020-10-03 13:35:05 +08:00
val NamedDomainObjectContainer<KotlinSourceSet>.androidMain: NamedDomainObjectProvider<KotlinSourceSet>
get() = named<KotlinSourceSet>("androidMain")
val NamedDomainObjectContainer<KotlinSourceSet>.androidTest: NamedDomainObjectProvider<KotlinSourceSet>
get() = named<KotlinSourceSet>("androidTest")
val NamedDomainObjectContainer<KotlinSourceSet>.jvmMain: NamedDomainObjectProvider<KotlinSourceSet>
get() = named<KotlinSourceSet>("jvmMain")
val NamedDomainObjectContainer<KotlinSourceSet>.jvmTest: NamedDomainObjectProvider<KotlinSourceSet>
get() = named<KotlinSourceSet>("jvmTest")
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")
}
2020-08-18 09:24:44 +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) {
2020-08-18 09:24:44 +08:00
override fun getDefaultExtension() = "module"
})
}
}
}
}