Skip to content

Commit 17f7fb8

Browse files
committed
Register third-party plugins before kapt
1 parent 5b95782 commit 17f7fb8

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.idea/.gitignore

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/kotlin/com/tschuchort/compiletesting/MainComponentRegistrar.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,20 @@ internal class MainComponentRegistrar : ComponentRegistrar {
2626

2727
override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
2828
val parameters = threadLocalParameters.get()
29-
KaptComponentRegistrar(parameters.processors,parameters.kaptOptions).registerProjectComponents(project,configuration)
3029

30+
/*
31+
The order of registering plugins here matters. If the kapt plugin is registered first, then
32+
it will be executed first and any changes made to the AST by later plugins won't apply to the
33+
generated stub files and thus won't be visible to any annotation processors. So we decided
34+
to register third-party plugins before kapt and hope that it works, although we don't
35+
know for sure if that is the correct way.
36+
*/
3137
parameters.compilerPlugins.forEach { componentRegistrar->
3238
componentRegistrar.registerProjectComponents(project,configuration)
3339
}
40+
41+
KaptComponentRegistrar(parameters.processors, parameters.kaptOptions)
42+
.registerProjectComponents(project,configuration)
3443
}
3544

3645
companion object {

0 commit comments

Comments
 (0)