@@ -69,6 +69,16 @@ var KotlinCompilation.kspIncrementalLog: Boolean
6969 registrar.incrementalLog = value
7070 }
7171
72+ /* *
73+ * Controls for enabling all warnings as errors in KSP.
74+ */
75+ var KotlinCompilation .allWarningsAsErrors: Boolean
76+ get() = getKspRegistrar().allWarningsAsErrors
77+ set(value) {
78+ val registrar = getKspRegistrar()
79+ registrar.allWarningsAsErrors = value
80+ }
81+
7282private val KotlinCompilation .kspJavaSourceDir: File
7383 get() = kspSourcesDir.resolve(" java" )
7484
@@ -129,6 +139,7 @@ private class KspCompileTestingComponentRegistrar(
129139
130140 var incremental: Boolean = false
131141 var incrementalLog: Boolean = false
142+ var allWarningsAsErrors: Boolean = false
132143
133144 override fun registerProjectComponents (project : MockProject , configuration : CompilerConfiguration ) {
134145 if (providers.isEmpty()) {
@@ -141,6 +152,7 @@ private class KspCompileTestingComponentRegistrar(
141152
142153 this .incremental = this @KspCompileTestingComponentRegistrar.incremental
143154 this .incrementalLog = this @KspCompileTestingComponentRegistrar.incrementalLog
155+ this .allWarningsAsErrors = this @KspCompileTestingComponentRegistrar.allWarningsAsErrors
144156
145157 this .cachesDir = compilation.kspCachesDir.also {
146158 it.deleteRecursively()
@@ -181,7 +193,8 @@ private class KspCompileTestingComponentRegistrar(
181193 compilation.internalMessageStreamAccess,
182194 MessageRenderer .GRADLE_STYLE ,
183195 compilation.verbose
184- )
196+ ),
197+ allWarningsAsErrors
185198 )
186199 val registrar = KspTestExtension (options, providers, messageCollectorBasedKSPLogger)
187200 AnalysisHandlerExtension .registerExtension(project, registrar)
0 commit comments