File tree 2 files changed +46
-2
lines changed
2 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -104,8 +104,23 @@ 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
+ getAdditionalKotlinCompilerOptions(project).let {
118
+ freeCompilerArgs.addAll(it)
119
+ }
120
+ }
121
+ doFirst {
122
+ logger.info(" Added Kotlin compiler flags: ${compilerOptions.freeCompilerArgs.get().joinToString(" , " )} " )
123
+ logger.info(" allWarningsAsErrors=${compilerOptions.allWarningsAsErrors.get()} " )
109
124
}
110
125
}
111
126
}
Original file line number Diff line number Diff line change @@ -75,4 +75,33 @@ 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
+ val parsedOpts = opts?.split(' ' ).orEmpty()
88
+ if (parsedOpts.isNotEmpty()) {
89
+ project.logger.info(""" Configured Kotlin compiler options: '$opts ' for project ${project.name} """ )
90
+ }
91
+ return parsedOpts
92
+ }
93
+
94
+ /* *
95
+ * Check if `allWarningsAsErrors` was configured to be set using the `kotlin_Werror_override` property.
96
+ *
97
+ * @return `true` if `kotlin_Werror_override` was set to `enable` or it was not specified at all, `false` if it was set to `disable`.
98
+ */
99
+ fun getAllWarningsAsErrorsValue (project : Project ): Boolean {
100
+ val werrorOverride = project.providers.gradleProperty(" kotlin_Werror_override" ).orNull ? : return true
101
+ project.logger.info(""" Configured kotlin_Werror_override: '$werrorOverride ' for project ${project.name} """ )
102
+ return when (werrorOverride) {
103
+ " enable" -> true
104
+ " disable" -> false
105
+ else -> error(" Unexpected value for 'kotlin_Werror_override' property: $werrorOverride " )
106
+ }
107
+ }
You can’t perform that action at this time.
0 commit comments