Skip to content

Commit 57759ea

Browse files
authored
Adopt KUP requirements imposed by KT-75078 (#214)
* Adopt KUP requirements imposed by KT-75078 Closes #212
1 parent 5c3af1e commit 57759ea

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

build.gradle.kts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,29 @@ allprojects {
4646
}
4747
}
4848

49+
val setAllWarningsAsError = providers.gradleProperty("kotlin_Werror_override").map {
50+
when (it) {
51+
"enable" -> true
52+
"disable" -> false
53+
else -> error("Unexpected value for 'kotlin_Werror_override' property: $it")
54+
}
55+
}
56+
4957
tasks.withType(KotlinCompilationTask::class).configureEach {
5058
compilerOptions {
51-
allWarningsAsErrors = true
52-
freeCompilerArgs.add("-Xexpect-actual-classes")
59+
if (setAllWarningsAsError.orNull != false) {
60+
allWarningsAsErrors = true
61+
} else {
62+
freeCompilerArgs.addAll(
63+
"-Wextra",
64+
"-Xuse-fir-experimental-checkers"
65+
)
66+
}
67+
freeCompilerArgs.addAll(
68+
"-Xexpect-actual-classes",
69+
"-Xreport-all-warnings",
70+
"-Xrender-internal-diagnostic-names"
71+
)
5372
}
5473
if (this is KotlinJsCompile) {
5574
compilerOptions {
@@ -60,6 +79,18 @@ allprojects {
6079
freeCompilerArgs.add("-Xjvm-default=disable")
6180
}
6281
}
82+
83+
val extraOpts = providers.gradleProperty("kotlin_additional_cli_options").orNull
84+
extraOpts?.split(' ')?.map(String::trim)?.filter(String::isNotBlank)?.let { opts ->
85+
if (opts.isNotEmpty()) {
86+
compilerOptions.freeCompilerArgs.addAll(opts)
87+
}
88+
}
89+
90+
doFirst {
91+
logger.info("Added Kotlin compiler flags: ${compilerOptions.freeCompilerArgs.get().joinToString(", ")}")
92+
logger.info("allWarningsAsErrors=${compilerOptions.allWarningsAsErrors.get()}")
93+
}
6394
}
6495
}
6596

0 commit comments

Comments
 (0)