@@ -46,10 +46,29 @@ allprojects {
46
46
}
47
47
}
48
48
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
+
49
57
tasks.withType(KotlinCompilationTask ::class ).configureEach {
50
58
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
+ )
53
72
}
54
73
if (this is KotlinJsCompile ) {
55
74
compilerOptions {
@@ -60,6 +79,18 @@ allprojects {
60
79
freeCompilerArgs.add(" -Xjvm-default=disable" )
61
80
}
62
81
}
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
+ }
63
94
}
64
95
}
65
96
0 commit comments