Neon
02/12/2026, 11:58 PMCLOVIS
02/13/2026, 2:01 PMthen generate additional methods with KSP inheriting from it (zero or almost zero cost at runtime)Downsides: • Two interfaces in the public API • The documentation of both is in different pages in Dokka output
CLOVIS
02/13/2026, 2:02 PMAnother workaround without own compiler plugin magic (which IMHO probably is unjustified, as well as code-generation in general) is to have two source-sets (and two compilations in KGP) and generate a duplicate with KSP + KotlinPoet and expose only compiled code from the non-template source setThat's interesting 🤔 But doesn't that require the other module to have access to the first's classpath? Since KSP can only generate code within the current module.
Neon
02/13/2026, 2:03 PMNeon
02/13/2026, 2:05 PMCLOVIS
02/13/2026, 2:06 PMNeon
02/13/2026, 2:08 PMNeon
02/13/2026, 2:09 PMCLOVIS
02/13/2026, 2:10 PMCLOVIS
02/13/2026, 2:10 PMCLOVIS
02/13/2026, 2:10 PMNeon
02/13/2026, 2:11 PMNeon
02/13/2026, 2:11 PMNeon
02/13/2026, 2:14 PMhfhbd
02/13/2026, 2:17 PMCLOVIS
02/13/2026, 2:23 PMhfhbd
02/13/2026, 2:25 PMNeon
02/13/2026, 2:25 PMCLOVIS
02/13/2026, 2:26 PMNeon
02/13/2026, 2:26 PMNeon
02/13/2026, 2:27 PMNeon
02/13/2026, 2:27 PMCLOVIS
02/13/2026, 2:28 PMAnd what about generating all the operators with kotlinpoet in a custom Gradle task? I would not expect to write 600 operators by hand at all 😅
I guess, the operators are mostly the same, but requires different parameters.Different names, different parameters, different type parameters, different documentation…
hfhbd
02/13/2026, 2:32 PMDifferent names, different parameters, different type parameters, different documentation…Yes, but you could use loops. Anyway it was just an idea to not write any "Kotlin" code by hand but move the logic into a generator. The generator/the data model of the operators will be big, for sure (unless you can also scrap the operators from the mongoDB documentation)
CLOVIS
02/13/2026, 4:05 PMunless you can also scrap the operators from the mongoDB documentationThis is not feasible. I tweak many of them to fit better into Kotlin, etc.