Skip to content

Commit f65d96d

Browse files
committed
Additional compiler arguments as per KT-75078
1 parent f3aa685 commit f65d96d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

build-settings-logic/src/main/kotlin/ktorbuild.kotlin-user-project.settings.gradle.kts

+27
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.gradle.dsl.*
1414
* - `kotlin_repo_url` defines additional repository to be added to the repository list
1515
* - `kotlin_language_version` overrides Kotlin language versions
1616
* - `kotlin_api_version` overrides Kotlin API version
17+
* - `kotlin_additional_cli_options` additional CLI options for the Kotlin compiler
1718
*
1819
* Ktor Train:
1920
* All the above properties are applied, and:
@@ -53,6 +54,14 @@ val kotlinApiVersion by lazy {
5354
.orNull
5455
?.also { log("Kotlin API version: ${it.version}") }
5556
}
57+
val kotlinAdditionalCliOptions by lazy {
58+
val spacesRegex = "\\s+".toRegex()
59+
providers.gradleProperty("kotlin_additional_cli_options")
60+
.map { it.trim { it == '"' || it.isWhitespace() }.split(spacesRegex).filterNot(String::isEmpty) }
61+
.orNull
62+
?.also { log("Kotlin additional CLI options: $it") }
63+
.orEmpty()
64+
}
5665

5766
pluginManagement {
5867
repositories {
@@ -88,10 +97,28 @@ gradle.afterProject {
8897
languageVersion = version
8998
log("$path : Set Kotlin LV $version")
9099
}
100+
91101
kotlinApiVersion?.let { version ->
92102
apiVersion = version
93103
log("$path : Set Kotlin APIV $version")
94104
}
105+
106+
// Unconditionally disable the -Werror option
107+
allWarningsAsErrors = false
108+
109+
val argsToAdd = listOf(
110+
// Output reported warnings even in the presence of reported errors
111+
"-Xreport-all-warnings",
112+
// Output kotlin.git-searchable names of reported diagnostics
113+
"-Xrender-internal-diagnostic-names",
114+
// Opt into additional warning-reporting compilation checks
115+
"-Wextra",
116+
// Opt into additional compilation checks hidden from users
117+
"-Xuse-fir-experimental-checkers",
118+
) + kotlinAdditionalCliOptions
119+
120+
freeCompilerArgs.addAll(argsToAdd)
121+
log("$path : Added ${argsToAdd.joinToString(" ")}")
95122
}
96123
}
97124

0 commit comments

Comments
 (0)