Remove Gradle Isolated Project violation
Calls to Project.properties is not Gradle Isolated Projects safe as it
causes Gradle to look through parent projects to find these. Move to
using providers.gradleProperty as that does not have the same behavior.
Test: ./gradlew build --dry-run -Dorg.gradle.unsafe.isolated-projects=true
fewer warnings after the PR
This commit is contained in:
@@ -23,7 +23,6 @@ import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.kotlin.dsl.assign
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.dependencies
|
||||
import org.gradle.kotlin.dsl.provideDelegate
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinBaseExtension
|
||||
@@ -78,14 +77,16 @@ internal fun Project.configureKotlinJvm() {
|
||||
private inline fun <reified T : KotlinBaseExtension> Project.configureKotlin() = configure<T> {
|
||||
// Treat all Kotlin warnings as errors (disabled by default)
|
||||
// Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties
|
||||
val warningsAsErrors: String? by project
|
||||
val warningsAsErrors = providers.gradleProperty("warningsAsErrors").map {
|
||||
it.toBoolean()
|
||||
}.orElse(false)
|
||||
when (this) {
|
||||
is KotlinAndroidProjectExtension -> compilerOptions
|
||||
is KotlinJvmProjectExtension -> compilerOptions
|
||||
else -> TODO("Unsupported project extension $this ${T::class}")
|
||||
}.apply {
|
||||
jvmTarget = JvmTarget.JVM_11
|
||||
allWarningsAsErrors = warningsAsErrors.toBoolean()
|
||||
allWarningsAsErrors = warningsAsErrors
|
||||
freeCompilerArgs.add(
|
||||
// Enable experimental coroutines APIs, including Flow
|
||||
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
||||
|
||||
Reference in New Issue
Block a user