Librechat-Mobile/build-logic/convention/src/main/kotlin/KmpLibraryConventionPlugin.kt
Tim Abil 08f8445ea8 fix: bump JVM toolchain to 21 and centralize build constants
Extract JVM_TOOLCHAIN_VERSION, COMPILE_SDK, MIN_SDK, and TARGET_SDK
into a shared BuildConstants object so all convention plugins reference
a single source of truth.
2026-04-06 23:53:05 -04:00

60 lines
2.2 KiB
Kotlin

import com.android.build.gradle.LibraryExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
class KmpLibraryConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("com.android.library")
pluginManager.apply("org.jetbrains.kotlin.multiplatform")
pluginManager.apply("librechat.mobile.detekt")
pluginManager.apply("org.jetbrains.kotlinx.kover")
extensions.configure<KotlinMultiplatformExtension> {
jvmToolchain(BuildConstants.JVM_TOOLCHAIN_VERSION)
compilerOptions {
freeCompilerArgs.addAll(
"-opt-in=kotlin.time.ExperimentalTime",
)
}
androidTarget()
iosArm64()
iosSimulatorArm64()
sourceSets.commonTest.dependencies {
implementation(kotlin("test"))
}
sourceSets.named("androidUnitTest").configure {
dependencies {
implementation(libs.findBundle("testing").get())
}
}
}
extensions.configure<LibraryExtension> {
compileSdk = BuildConstants.COMPILE_SDK
defaultConfig {
minSdk = BuildConstants.MIN_SDK
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
lint {
disable += "NullSafeMutableLiveData"
}
testOptions {
unitTests.isReturnDefaultValues = true
}
}
dependencies.add("coreLibraryDesugaring", libs.findLibrary("desugar-jdk").get())
}
}
}
private val Project.libs
get() = extensions.getByType(org.gradle.api.artifacts.VersionCatalogsExtension::class.java)
.named("libs")