|
|
|
@ -20,11 +20,11 @@ import com.android.build.api.dsl.CommonExtension
|
|
|
|
|
import org.gradle.api.JavaVersion
|
|
|
|
|
import org.gradle.api.Project
|
|
|
|
|
import org.gradle.api.artifacts.VersionCatalogsExtension
|
|
|
|
|
import org.gradle.api.plugins.ExtensionAware
|
|
|
|
|
import org.gradle.kotlin.dsl.dependencies
|
|
|
|
|
import org.gradle.kotlin.dsl.getByType
|
|
|
|
|
import org.gradle.kotlin.dsl.provideDelegate
|
|
|
|
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
|
|
|
|
|
import org.gradle.kotlin.dsl.withType
|
|
|
|
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Configure base Kotlin with Android options
|
|
|
|
@ -40,17 +40,21 @@ internal fun Project.configureKotlinAndroid(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
compileOptions {
|
|
|
|
|
sourceCompatibility = JavaVersion.VERSION_11
|
|
|
|
|
targetCompatibility = JavaVersion.VERSION_11
|
|
|
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
|
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
|
|
|
isCoreLibraryDesugaringEnabled = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use withType to workaround https://youtrack.jetbrains.com/issue/KT-55947
|
|
|
|
|
tasks.withType<KotlinCompile>().configureEach {
|
|
|
|
|
kotlinOptions {
|
|
|
|
|
// Set JVM target to 17
|
|
|
|
|
jvmTarget = JavaVersion.VERSION_17.toString()
|
|
|
|
|
// Treat all Kotlin warnings as errors (disabled by default)
|
|
|
|
|
// Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties
|
|
|
|
|
val warningsAsErrors: String? by project
|
|
|
|
|
allWarningsAsErrors = warningsAsErrors.toBoolean()
|
|
|
|
|
|
|
|
|
|
freeCompilerArgs = freeCompilerArgs + listOf(
|
|
|
|
|
"-opt-in=kotlin.RequiresOptIn",
|
|
|
|
|
// Enable experimental coroutines APIs, including Flow
|
|
|
|
@ -58,9 +62,6 @@ internal fun Project.configureKotlinAndroid(
|
|
|
|
|
"-opt-in=kotlinx.coroutines.FlowPreview",
|
|
|
|
|
"-opt-in=kotlin.Experimental",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Set JVM target to 11
|
|
|
|
|
jvmTarget = JavaVersion.VERSION_11.toString()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -70,7 +71,3 @@ internal fun Project.configureKotlinAndroid(
|
|
|
|
|
add("coreLibraryDesugaring", libs.findLibrary("android.desugarJdkLibs").get())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun CommonExtension<*, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) {
|
|
|
|
|
(this as ExtensionAware).extensions.configure("kotlinOptions", block)
|
|
|
|
|
}
|
|
|
|
|