XuqmGroup-AndroidSDK/sdk-core/build.gradle.kts

82 行
2.5 KiB
Plaintext

2026-04-21 22:07:29 +08:00
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.compose)
2026-04-21 22:07:29 +08:00
alias(libs.plugins.kotlin.serialization)
}
apply(from = rootProject.file("gradle/publish.gradle"))
version = providers.gradleProperty("SDK_CORE_VERSION")
.orElse(providers.gradleProperty("PUBLISH_VERSION"))
.getOrElse("0.1.0-SNAPSHOT")
2026-04-21 22:07:29 +08:00
android {
namespace = "com.xuqm.sdk.core"
compileSdk = libs.versions.compileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
consumerProguardFiles("consumer-rules.pro")
}
2026-04-21 22:07:29 +08:00
compileOptions {
isCoreLibraryDesugaringEnabled = true
2026-04-21 22:07:29 +08:00
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
buildFeatures {
compose = true
}
publishing {
singleVariant("release") {
withSourcesJar()
}
}
2026-04-21 22:07:29 +08:00
}
dependencies {
api(platform(libs.androidx.compose.bom))
// sdk-core 会进入原生、RN 与 Flutter 等不同宿主。通过 BOM 统一所有
// okhttp 组件(含宿主已有的 okhttp-urlconnection,避免同一 APK
// 混装 4.x 扩展与 5.x 主包造成运行时链接崩溃。
api(platform(libs.okhttp.bom))
2026-04-21 22:07:29 +08:00
api(libs.bundles.network)
api(libs.kotlinx.coroutines.android)
api(libs.kotlinx.serialization.json)
api(libs.androidx.core.ktx)
implementation(libs.bouncycastle)
api(libs.androidx.ui)
api(libs.androidx.material3)
testImplementation(libs.junit4)
coreLibraryDesugaring(libs.desugar.jdk.libs)
2026-04-21 22:07:29 +08:00
}
val verifyNetworkDependencyAlignment by tasks.registering {
group = "verification"
description = "校验 sdk-core 的 OkHttp 组件均处于同一条二进制兼容线。"
doLast {
val expected = libs.versions.okhttp.get()
val resolved = configurations.getByName("releaseRuntimeClasspath")
.resolvedConfiguration
.resolvedArtifacts
.mapNotNull { artifact ->
val id = artifact.moduleVersion.id
if (id.group == "com.squareup.okhttp3") id else null
}
.distinctBy { "${it.group}:${it.name}" }
val incompatible = resolved.filter { it.version != expected }
check(incompatible.isEmpty()) {
"OkHttp 组件未对齐到 $expected" +
incompatible.joinToString { "${it.group}:${it.name}:${it.version}" }
}
}
}
tasks.named("check").configure {
dependsOn(verifyNetworkDependencyAlignment)
}