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