1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-04-25 13:03:35 +08:00

[build] Relocate ktor only for jvm, not for Android

This commit is contained in:
Him188 2023-04-17 15:42:50 +01:00
parent 164f621427
commit a2d50ec03a
3 changed files with 26 additions and 1 deletions
buildSrc/src/main/kotlin
mirai-core-utils
mirai-core

View File

@ -125,6 +125,7 @@ private fun KotlinTarget.configureRelocationForMppTarget(project: Project) = pro
// We will modify Kotlin metadata, so do generate metadata before relocation
val generateMetadataTask =
tasks.getByName("generateMetadataFileFor${targetName.capitalize()}Publication") as GenerateModuleMetadata
generateMetadataTask.dependsOn(relocateDependencies)
val patchMetadataTask = tasks.create("patchMetadataFileFor${targetName.capitalize()}RelocatedPublication") {
dependsOn(generateMetadataTask)

View File

@ -41,6 +41,15 @@ kotlin {
relocateImplementation(`ktor-io_relocated`)
}
}
configure(NATIVE_TARGETS.map { getByName(it + "Main") }
+ NATIVE_TARGETS.map { getByName(it + "Test") }) {
dependencies {
// no relocation in native
implementation(`ktor-io`) {
exclude(ExcludeProperties.`slf4j-api`)
}
}
}
val commonTest by getting {
dependencies {

View File

@ -120,13 +120,28 @@ kotlin {
// Ktor
findByName("commonMain")?.apply {
dependencies {
compileOnly(`ktor-io`)
implementation(`ktor-client-core`)
}
}
findByName("jvmBaseMain")?.apply {
// relocate for JVM like modules
dependencies {
relocateCompileOnly(`ktor-io_relocated`) // runtime from mirai-core-utils
relocateImplementation(`ktor-client-core_relocated`)
}
}
configure(NATIVE_TARGETS.map { getByName(it + "Main") }
+ NATIVE_TARGETS.map { getByName(it + "Test") }) {
// no relocation in native, include binaries
dependencies {
api(`ktor-io`) {
exclude(ExcludeProperties.`slf4j-api`)
}
}
}
findByName("jvmBaseMain")?.apply {
dependencies {
relocateImplementation(`ktor-client-okhttp_relocated`)