Merge pull request #17 from garfiec/fix/jvm-toolchain-alignment
fix: use jvmToolchain(17) to align Java and Kotlin JVM targets
This commit is contained in:
commit
a014b99597
4 changed files with 21 additions and 28 deletions
|
|
@ -2,8 +2,7 @@ import com.android.build.api.dsl.ApplicationExtension
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.configure
|
import org.gradle.kotlin.dsl.configure
|
||||||
import org.gradle.kotlin.dsl.withType
|
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
||||||
|
|
||||||
class AndroidApplicationConventionPlugin : Plugin<Project> {
|
class AndroidApplicationConventionPlugin : Plugin<Project> {
|
||||||
override fun apply(target: Project) {
|
override fun apply(target: Project) {
|
||||||
|
|
@ -13,24 +12,23 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
|
||||||
pluginManager.apply("librechat.mobile.detekt")
|
pluginManager.apply("librechat.mobile.detekt")
|
||||||
pluginManager.apply("org.jetbrains.kotlinx.kover")
|
pluginManager.apply("org.jetbrains.kotlinx.kover")
|
||||||
|
|
||||||
tasks.withType<KotlinCompile>().configureEach {
|
extensions.configure<KotlinAndroidProjectExtension> {
|
||||||
|
jvmToolchain(BuildConstants.JVM_TOOLCHAIN_VERSION)
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
freeCompilerArgs.addAll("-opt-in=kotlin.time.ExperimentalTime")
|
freeCompilerArgs.addAll("-opt-in=kotlin.time.ExperimentalTime")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extensions.configure<ApplicationExtension> {
|
extensions.configure<ApplicationExtension> {
|
||||||
compileSdk = 36
|
compileSdk = BuildConstants.COMPILE_SDK
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = 26
|
minSdk = BuildConstants.MIN_SDK
|
||||||
targetSdk = 35
|
targetSdk = BuildConstants.TARGET_SDK
|
||||||
versionCode = 1
|
versionCode = 1
|
||||||
versionName = "0.1.0"
|
versionName = "0.1.0"
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = org.gradle.api.JavaVersion.VERSION_17
|
|
||||||
targetCompatibility = org.gradle.api.JavaVersion.VERSION_17
|
|
||||||
isCoreLibraryDesugaringEnabled = true
|
isCoreLibraryDesugaringEnabled = true
|
||||||
}
|
}
|
||||||
lint {
|
lint {
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,7 @@ import com.android.build.gradle.LibraryExtension
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.configure
|
import org.gradle.kotlin.dsl.configure
|
||||||
import org.gradle.kotlin.dsl.withType
|
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
||||||
|
|
||||||
class AndroidLibraryConventionPlugin : Plugin<Project> {
|
class AndroidLibraryConventionPlugin : Plugin<Project> {
|
||||||
override fun apply(target: Project) {
|
override fun apply(target: Project) {
|
||||||
|
|
@ -13,21 +12,20 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
|
||||||
pluginManager.apply("librechat.mobile.detekt")
|
pluginManager.apply("librechat.mobile.detekt")
|
||||||
pluginManager.apply("org.jetbrains.kotlinx.kover")
|
pluginManager.apply("org.jetbrains.kotlinx.kover")
|
||||||
|
|
||||||
tasks.withType<KotlinCompile>().configureEach {
|
extensions.configure<KotlinAndroidProjectExtension> {
|
||||||
|
jvmToolchain(BuildConstants.JVM_TOOLCHAIN_VERSION)
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
freeCompilerArgs.addAll("-opt-in=kotlin.time.ExperimentalTime")
|
freeCompilerArgs.addAll("-opt-in=kotlin.time.ExperimentalTime")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extensions.configure<LibraryExtension> {
|
extensions.configure<LibraryExtension> {
|
||||||
compileSdk = 36
|
compileSdk = BuildConstants.COMPILE_SDK
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = 26
|
minSdk = BuildConstants.MIN_SDK
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = org.gradle.api.JavaVersion.VERSION_17
|
|
||||||
targetCompatibility = org.gradle.api.JavaVersion.VERSION_17
|
|
||||||
isCoreLibraryDesugaringEnabled = true
|
isCoreLibraryDesugaringEnabled = true
|
||||||
}
|
}
|
||||||
lint {
|
lint {
|
||||||
|
|
|
||||||
6
build-logic/convention/src/main/kotlin/BuildConstants.kt
Normal file
6
build-logic/convention/src/main/kotlin/BuildConstants.kt
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
object BuildConstants {
|
||||||
|
const val JVM_TOOLCHAIN_VERSION = 21
|
||||||
|
const val COMPILE_SDK = 36
|
||||||
|
const val MIN_SDK = 26
|
||||||
|
const val TARGET_SDK = 35
|
||||||
|
}
|
||||||
|
|
@ -13,20 +13,13 @@ class KmpLibraryConventionPlugin : Plugin<Project> {
|
||||||
pluginManager.apply("org.jetbrains.kotlinx.kover")
|
pluginManager.apply("org.jetbrains.kotlinx.kover")
|
||||||
|
|
||||||
extensions.configure<KotlinMultiplatformExtension> {
|
extensions.configure<KotlinMultiplatformExtension> {
|
||||||
|
jvmToolchain(BuildConstants.JVM_TOOLCHAIN_VERSION)
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
freeCompilerArgs.addAll(
|
freeCompilerArgs.addAll(
|
||||||
"-opt-in=kotlin.time.ExperimentalTime",
|
"-opt-in=kotlin.time.ExperimentalTime",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
androidTarget {
|
androidTarget()
|
||||||
compilations.configureEach {
|
|
||||||
compileTaskProvider.configure {
|
|
||||||
compilerOptions {
|
|
||||||
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
iosArm64()
|
iosArm64()
|
||||||
iosSimulatorArm64()
|
iosSimulatorArm64()
|
||||||
|
|
||||||
|
|
@ -41,14 +34,12 @@ class KmpLibraryConventionPlugin : Plugin<Project> {
|
||||||
}
|
}
|
||||||
|
|
||||||
extensions.configure<LibraryExtension> {
|
extensions.configure<LibraryExtension> {
|
||||||
compileSdk = 36
|
compileSdk = BuildConstants.COMPILE_SDK
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = 26
|
minSdk = BuildConstants.MIN_SDK
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = org.gradle.api.JavaVersion.VERSION_17
|
|
||||||
targetCompatibility = org.gradle.api.JavaVersion.VERSION_17
|
|
||||||
isCoreLibraryDesugaringEnabled = true
|
isCoreLibraryDesugaringEnabled = true
|
||||||
}
|
}
|
||||||
lint {
|
lint {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue