Skip to content

Adopt KUP requirements imposed by KT-75078 #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,29 @@ allprojects {
}
}

val setAllWarningsAsError = providers.gradleProperty("kotlin_Werror_override").map {
when (it) {
"enable" -> true
"disable" -> false
else -> error("Unexpected value for 'kotlin_Werror_override' property: $it")
}
}

tasks.withType(KotlinCompilationTask::class).configureEach {
compilerOptions {
allWarningsAsErrors = true
freeCompilerArgs.add("-Xexpect-actual-classes")
if (setAllWarningsAsError.orNull != false) {
allWarningsAsErrors = true
} else {
freeCompilerArgs.addAll(
"-Wextra",
"-Xuse-fir-experimental-checkers"
)
}
freeCompilerArgs.addAll(
"-Xexpect-actual-classes",
"-Xreport-all-warnings",
"-Xrender-internal-diagnostic-names"
)
}
if (this is KotlinJsCompile) {
compilerOptions {
Expand All @@ -60,6 +79,18 @@ allprojects {
freeCompilerArgs.add("-Xjvm-default=disable")
}
}

val extraOpts = providers.gradleProperty("kotlin_additional_cli_options").orNull
extraOpts?.split(' ')?.map(String::trim)?.filter(String::isNotBlank)?.let { opts ->
if (opts.isNotEmpty()) {
compilerOptions.freeCompilerArgs.addAll(opts)
}
}

doFirst {
logger.info("Added Kotlin compiler flags: ${compilerOptions.freeCompilerArgs.get().joinToString(", ")}")
logger.info("allWarningsAsErrors=${compilerOptions.allWarningsAsErrors.get()}")
}
}
}

Expand Down