Matthias Geisler
03/22/2022, 5:12 PMJiaxiang
03/22/2022, 5:58 PMMatthias Geisler
03/22/2022, 6:21 PMcreateNewFile
so it can simply exchange it when it invokes pathOf
. Not sure how it affects associate
or associateWithClasses
since I am not totally sure what they are exactly meant for, but it should work similarly.
The propagation could be either be done via `Dependency`(however I am not sure it is a good fit), or directly with an additional arg of the mentioned methods. To comply with the folder structure this argument must be the full name of the sourceSet which gets strip down (commonTest -> common).
I currently make a custom implementation of the CodeGenerator which is basically a strip down version of CodeGeneratorImpl
but cannot make use of the sweet features which come with the internal Generator. So I think KSP could do it directly.
Well, what do you think?Alex Vanyo
03/22/2022, 11:05 PMMatthias Geisler
03/23/2022, 1:45 AMCodeGeneratorImpl
gets currently on its constructor. This solves the problem indirectly since consumers can implement their own Generator with additional capabilities while not necessarily losing any features which comes with the internal Generator. The factories could be similar propagated like a processor to KSP. This way is even more flexible but pushes all responsibility on consumers. Either way I am willing to contribute if wanted.Ting-Yuan Huang
03/27/2022, 7:29 AMthe trouble why KSP is not aware of shared sources/meta sources like commonTestDo you mean: 1. generated code / computation done by processors can't be shared, or 2. commond code can't be processed separately from target code?
Matthias Geisler
03/27/2022, 7:35 AMMatthias Geisler
03/27/2022, 7:57 AMTing-Yuan Huang
03/27/2022, 8:34 AMMatthias Geisler
03/27/2022, 8:43 AMKSP currently follows Kotlin MPP's compilation model, which compiles shared sources sets multiple times with target specific source sets.
Thats what I meant in the beginning at this thread - I get that totally. The point here is the compiler are totally happy with that, but developers will not, since a IDE will not be able to resolve generated sources correctly unless they are put in the correct source folder.
Since the CodeGenerator is technically not involved in the analysis process, it will not interfere with KSP primary logic. Additionally KSP already exposes the Interface of the CodeGenerator, so technically it is already possible to exchange it with a custom one (like I did), but the optimisations are gone. While I get your point with incompatibilities, I think more and more my 2nd proposal is the better one (aka Factory), since it would allow still to differ between an intern implementation and consumer induced one, but providing consumers with tools to keep the optimisations like the internal Generator. This might keeps also problems with incompatibility at bay.
Summa summarum - I'd like either to somehow tell the CodeGenerator where to put sources or to get the tools (I believe that has something to do with here) to behave similar to the internal one.
However in the end you have to decide and I appreciate any solution, which does not fall behind the current possibilities.