82 行
2.5 KiB
Plaintext
82 行
2.5 KiB
Plaintext
plugins {
|
||
alias(libs.plugins.android.library)
|
||
alias(libs.plugins.kotlin.compose)
|
||
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")
|
||
|
||
android {
|
||
namespace = "com.xuqm.sdk.core"
|
||
compileSdk = libs.versions.compileSdk.get().toInt()
|
||
|
||
defaultConfig {
|
||
minSdk = libs.versions.minSdk.get().toInt()
|
||
consumerProguardFiles("consumer-rules.pro")
|
||
}
|
||
|
||
|
||
compileOptions {
|
||
isCoreLibraryDesugaringEnabled = true
|
||
sourceCompatibility = JavaVersion.VERSION_11
|
||
targetCompatibility = JavaVersion.VERSION_11
|
||
}
|
||
|
||
buildFeatures {
|
||
compose = true
|
||
}
|
||
|
||
publishing {
|
||
singleVariant("release") {
|
||
withSourcesJar()
|
||
}
|
||
}
|
||
}
|
||
|
||
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))
|
||
api(libs.bundles.network)
|
||
api(libs.kotlinx.coroutines.android)
|
||
api(libs.kotlinx.serialization.json)
|
||
api(libs.androidx.core.ktx)
|
||
api(libs.androidx.security.crypto)
|
||
api(libs.androidx.ui)
|
||
api(libs.androidx.material3)
|
||
testImplementation(libs.junit4)
|
||
coreLibraryDesugaring(libs.desugar.jdk.libs)
|
||
}
|
||
|
||
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)
|
||
}
|