Check out the nebula-kotlin-plugin. It seems very close to what you're trying to achieve there.
You’ll also like:
- Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15
- Parcelized sealed class with private constructor throws inaccessible error when getting from Intent in new activity but works everywhere else?