From b20af0196047900fe4ae621af2ee80bf52adbce8 Mon Sep 17 00:00:00 2001 From: Jolanda Verhoef Date: Tue, 23 Aug 2022 13:34:01 +0100 Subject: [PATCH] Read gradle property as string instead of boolean, gradle sync fails otherwise. --- .github/ci-gradle.properties | 2 +- .../com/google/samples/apps/nowinandroid/KotlinAndroid.kt | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/ci-gradle.properties b/.github/ci-gradle.properties index 54bc49dcb..1cd5c8496 100644 --- a/.github/ci-gradle.properties +++ b/.github/ci-gradle.properties @@ -25,4 +25,4 @@ kotlin.compiler.execution.strategy=in-process # 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 +warningsAsErrors="false" diff --git a/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/KotlinAndroid.kt b/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/KotlinAndroid.kt index 87d3e4b16..9df96c5cb 100644 --- a/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/KotlinAndroid.kt +++ b/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/KotlinAndroid.kt @@ -23,6 +23,7 @@ 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.extra import org.gradle.kotlin.dsl.getByType import org.gradle.kotlin.dsl.provideDelegate import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions @@ -52,9 +53,9 @@ internal fun Project.configureKotlinAndroid( 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 + val warningsAsErrors: String? by project + // Prefer local.properties, gradle.properties, or default to false when both are null + allWarningsAsErrors = localOverrideWarningsAsErrors ?: warningsAsErrors.toBoolean() freeCompilerArgs = freeCompilerArgs + listOf( "-opt-in=kotlin.RequiresOptIn",