tschuchortdev / kotlin-compile-testing

A library for testing Kotlin and Java annotation processors, compiler plugins and code generation
Mozilla Public License 2.0
659 stars 63 forks source link

Add 'withCompilation' to enable full compilation with symbol processors. #237

Closed bennyhuo closed 2 years ago

bennyhuo commented 2 years ago

This also fixes #191.

bennyhuo commented 2 years ago

Btw, it does not add the ksp generated sources to the compilation automatically by setting this option to true. Maybe we should do some additional work in the core library on ksp sources similar with the kapt sources to make this completely work.

tschuchortdev commented 2 years ago

Hi, thanks for your PR. Why did you close it again? It looks like a valuable addition, so I'd like to merge it.

bennyhuo commented 2 years ago

I find that it is not enough to make the ksp compilation work. The problem is that it does compile the sources with the option enabled but the generated sources by symbol processors do not be compiled in the same invokation.

So I move back to the workaround by compiling with symbol processsors to generate files first and then compiling the sources with the generated sources together.....

bennyhuo commented 2 years ago

Here is the workaround.

tschuchortdev commented 2 years ago

I see, but this PR only adds an extension property with the default still set to false so I think we can merge it and people can decide if they want to use it or not (even if it doesn't solve the problem).

To really solve all the problems with KSP once and for all, I suppose we would need a flexible extension system similar to Gradle tasks, but I want to keep the library as simple as possible. Maybe it is time that I move the KSP stuff into the core library (since KAPT is practically deprecated) and that would make things a lot easier.

bennyhuo commented 2 years ago

That would be great!