How to properly structure a Lombok like Kotlin compiler plugin

I am working on a Lombok like plugin for Kotlin classes. The source is here: GitHub - bivektor/lombokt: Lightweight port of Lombok utilities for Kotlin

My purpose is as follows:

  • Provide utilities like ToString and EqualsAndHashCode for Kotlin non-data classes (almost complete)
  • Provide support for Builders to have a neat Java API so that a Kotlin class with several constructor parameters can be used from Java through builders

I have a few questions:

  1. I have already implemented ToString and EqualsAndHashCode by registering declarations in FIR and implementing them in IR. Do I really need FIR for this or is IR enough?
  2. For the @Builder annotation, again, is IR enough as we don’t want the generated methods to be in the Kotlin class? And is it enough to implement a SyntheticJavaResolveExtension as in the official Kotlin Lombok plugin for IDE support?
  3. I structured the code similar to how official Kotlin plugins are structured i.e. a gradle project with submodules for backend, cli, k1, k2, common and all these modules are ultimately compiled into a single plugin jar. Is this really necessary and why does JetBrains choose such a project structure?

I have already implemented ToString and EqualsAndHashCode by registering declarations in FIR and implementing them in IR. Do I really need FIR for this or is IR enough?

IR is probably enough because you’re simply overriding a method and not adding a new one.