mirai/mirai-core-utils/build.gradle.kts
AdoptOSS 7325c1f7e2 native: 优化 build script 及 actions,修复 ECDH 相关资源释放问题 (#2110)
* build: fix build on Windows

* test: fix ContentEqualsTest on native

* build: allow disabling targets with property

* fix: free ECDH-related resources properly on native
avoid memory leaking (usually on *nix) or crash (usually on Windows)

Signed-off-by: AdoptOSS <adoptoss@outlook.com>

* build(workflow): remove invalid options

* fix(styling): `mirai.target` property

* build(workflow): try to limit memory usage during mirai-console:tools:gradle-plugin:integTest

* enhance(test): use buildList

* build(workflow): retry

Co-authored-by: ArcticLampyrid <arcticlampyrid@outlook.com>
2022-07-20 00:30:16 +08:00

116 lines
3.7 KiB
Plaintext

/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
*
* 此源代码的使用受 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/dev/LICENSE
*/
@file:Suppress("UNUSED_VARIABLE")
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
id("kotlinx-atomicfu")
id("me.him188.kotlin-jvm-blocking-bridge")
`maven-publish`
}
description = "mirai-core utilities"
kotlin {
explicitApi()
configureJvmTargetsHierarchical()
configureNativeTargetsHierarchical(project)
sourceSets {
val commonMain by getting {
dependencies {
api(kotlin("reflect"))
api(`kotlinx-serialization-core`)
api(`kotlinx-serialization-json`)
api(`kotlinx-coroutines-core`)
implementation(`kotlinx-atomicfu`)
implementation(`kotlinx-serialization-protobuf`)
implementation(`ktor-io`)
}
}
val commonTest by getting {
dependencies {
api(yamlkt)
implementation(`kotlinx-coroutines-test`)
}
}
findByName("jvmBaseMain")?.apply {
dependencies {
implementation(`jetbrains-annotations`)
}
}
findByName("androidMain")?.apply {
//
dependencies {
compileOnly(`android-runtime`)
// api1(`ktor-client-android`)
}
}
findByName("jvmMain")?.apply {
}
findByName("jvmTest")?.apply {
dependencies {
runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
}
}
findByName("nativeMain")?.apply {
dependencies {
// implementation("com.soywiz.korlibs.krypto:krypto:2.4.12") // ':mirai-core-utils:compileNativeMainKotlinMetadata' fails because compiler cannot find reference
}
}
}
}
if (tasks.findByName("androidMainClasses") != null) {
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")
}
tasks.getByName("androidTest").dependsOn("checkAndroidApiLevel")
}
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")
}
configureMppPublishing()