Skip to content

Commit e7d70b2

Browse files
bennyhuotschuchortdev
authored andcommitted
Add 'withCompilation' to enable full compilation with symbol processors. Fix #191.
1 parent 14a391b commit e7d70b2

File tree

1 file changed

+13
-0
lines changed
  • ksp/src/main/kotlin/com/tschuchort/compiletesting

1 file changed

+13
-0
lines changed

ksp/src/main/kotlin/com/tschuchort/compiletesting/Ksp.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ var KotlinCompilation.kspAllWarningsAsErrors: Boolean
7979
registrar.allWarningsAsErrors = value
8080
}
8181

82+
/**
83+
* Run processors and compilation in a single compiler invocation if true.
84+
* See [com.google.devtools.ksp.KspCliOption.WITH_COMPILATION_OPTION].
85+
*/
86+
var KotlinCompilation.kspWithCompilation: Boolean
87+
get() = getKspRegistrar().withCompilation
88+
set(value) {
89+
val registrar = getKspRegistrar()
90+
registrar.withCompilation = value
91+
}
92+
8293
private val KotlinCompilation.kspJavaSourceDir: File
8394
get() = kspSourcesDir.resolve("java")
8495

@@ -140,6 +151,7 @@ private class KspCompileTestingComponentRegistrar(
140151
var incremental: Boolean = false
141152
var incrementalLog: Boolean = false
142153
var allWarningsAsErrors: Boolean = false
154+
var withCompilation: Boolean = false
143155

144156
override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
145157
if (providers.isEmpty()) {
@@ -153,6 +165,7 @@ private class KspCompileTestingComponentRegistrar(
153165
this.incremental = this@KspCompileTestingComponentRegistrar.incremental
154166
this.incrementalLog = this@KspCompileTestingComponentRegistrar.incrementalLog
155167
this.allWarningsAsErrors = this@KspCompileTestingComponentRegistrar.allWarningsAsErrors
168+
this.withCompilation = this@KspCompileTestingComponentRegistrar.withCompilation
156169

157170
this.cachesDir = compilation.kspCachesDir.also {
158171
it.deleteRecursively()

0 commit comments

Comments
 (0)