Read warningsAsErrors from local.properties or gradle.properties, and default to false

pull/246/head
Jolanda Verhoef 2 years ago committed by Robert
parent bd0d1d25fb
commit 85a260e9ef

@ -21,5 +21,8 @@ org.gradle.workers.max=2
kotlin.incremental=false
kotlin.compiler.execution.strategy=in-process
# Controls KotlinOptions.allWarningsAsErrors. This is used in CI and can be set in local properties.
warningsAsErrors=true
# Controls KotlinOptions.allWarningsAsErrors.
# This value used in CI and is currently set to false.
# If you want to treat warnings as errors locally, set this property
# in local.properties.
warningsAsErrors=false

@ -24,6 +24,7 @@ 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
/**
@ -47,7 +48,13 @@ internal fun Project.configureKotlinAndroid(
kotlinOptions {
// Treat all Kotlin warnings as errors (disabled by default)
allWarningsAsErrors = gradleLocalProperties(rootDir).getProperty("warningsAsErrors").toBoolean()
// Override locally using local.properties
val localOverrideWarningsAsErrors = gradleLocalProperties(rootDir)
.getProperty("warningsAsErrors")?.toBoolean()
// Set on CI through gradle.properties
val warningsAsErrors: Boolean? by project
// Prefer local.properties, gradle.properties, or default to false
allWarningsAsErrors = localOverrideWarningsAsErrors ?: warningsAsErrors ?: false
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn",

Loading…
Cancel
Save