File tree Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -104,8 +104,21 @@ allprojects {
104
104
apiVersion = KotlinVersion .fromVersion(it)
105
105
}
106
106
107
+ freeCompilerArgs.addAll(" -Xreport-all-warnings" , " -Xrender-internal-diagnostic-names" )
108
+
107
109
progressiveMode = true
108
- allWarningsAsErrors = true
110
+
111
+ if (getAllWarningsAsErrorsValue(project)) {
112
+ allWarningsAsErrors = true
113
+ } else {
114
+ freeCompilerArgs.addAll(" -Wextra" , " -Xuse-fir-experimental-checkers" )
115
+ }
116
+
117
+ freeCompilerArgs.addAll(getAdditionalKotlinCompilerOptions(project))
118
+ }
119
+ doFirst {
120
+ logger.info(" Added Kotlin compiler flags: ${compilerOptions.freeCompilerArgs.get().joinToString(" , " )} " )
121
+ logger.info(" allWarningsAsErrors=${compilerOptions.allWarningsAsErrors.get()} " )
109
122
}
110
123
}
111
124
}
Original file line number Diff line number Diff line change @@ -75,4 +75,29 @@ fun getOverriddenKotlinNativeVersion(project: Project): String? {
75
75
project.logger.info(""" Configured Kotlin Native distribution version: '$nativeVersion ' for project ${project.name} """ )
76
76
}
77
77
return nativeVersion
78
- }
78
+ }
79
+
80
+ /* *
81
+ * Parses additional compiler options specified using the `kotlin_additional_cli_options` property.
82
+ *
83
+ * @return a list of additional options, or an empty list if none were specified
84
+ */
85
+ fun getAdditionalKotlinCompilerOptions (project : Project ): List <String > {
86
+ val opts = project.providers.gradleProperty(" kotlin_additional_cli_options" ).orNull
87
+ return opts?.split(' ' ).orEmpty().map(String ::trim).filter(String ::isNotBlank)
88
+ }
89
+
90
+ /* *
91
+ * Check if `allWarningsAsErrors` was configured to be set using the `kotlin_Werror_override` property.
92
+ *
93
+ * @return `true` if `kotlin_Werror_override` was set to `enable` or it was not specified at all, `false` if it was set to `disable`.
94
+ */
95
+ fun getAllWarningsAsErrorsValue (project : Project ): Boolean {
96
+ val werrorOverride = project.providers.gradleProperty(" kotlin_Werror_override" ).orNull ? : return true
97
+ project.logger.info(""" Configured kotlin_Werror_override: '$werrorOverride ' for project ${project.name} """ )
98
+ return when (werrorOverride) {
99
+ " enable" -> true
100
+ " disable" -> false
101
+ else -> error(" Unexpected value for 'kotlin_Werror_override' property: $werrorOverride " )
102
+ }
103
+ }
You can’t perform that action at this time.
0 commit comments