kotlin-compile-testing icon indicating copy to clipboard operation
kotlin-compile-testing copied to clipboard

How can I test multi-module annotation processing?

Open vinaygaba opened this issue 4 years ago • 5 comments

Not an issue per se but I was wondering how I can emulate a multi-module annotation processing setup where the processing runs separately for each module. I'd like to have some tests for this in particular as it's critical for my use case. Is this something that is already supported?

vinaygaba avatar Aug 05 '20 04:08 vinaygaba

I think the logic you are trying to test happens on the Gradle level outside the scope of KotlinCompilation. K2JVMCompiler has no concept of modules (beyond project jigsaw) as far as I know, so you'd have to take a look at how Gradle deals with modules and then emulate that with separate KotlinCompilations. That would be very useful as an addon to KotlinCompilation (I can assist you if you want to go that route). Or you can try to create a Gradle project on-the-fly and then run that but you'd lose all the benefits that Kotlin-Compile-Testing provides.

tschuchortdev avatar Aug 05 '20 07:08 tschuchortdev

Thanks for your reply! I'll have to do a bit of reading to completely wrap my head around how all this fits together. Would appreciate if you have any pointers I could use!

vinaygaba avatar Aug 09 '20 06:08 vinaygaba

AFAIK this stuff is completely undocumented and only passed on from person to person, so you will have to read the source code of the Kotlin Gradle Plugin or ask the authors. This could be useful as well: https://github.com/facebook/buck/tree/master/src/com/facebook/buck/jvm/kotlin

tschuchortdev avatar Aug 09 '20 10:08 tschuchortdev

Thank you for the recommendation!

vinaygaba avatar Aug 11 '20 15:08 vinaygaba

I am trying to add module support in this library: bennyhuo/kotlin-compile-testing-extensions, and it is used in bennyhuo/Mixin with a test data file Modules.kt.

bennyhuo avatar Jan 07 '22 13:01 bennyhuo