Putting everything into one project and avoiding closed source might solve the problem, but not necessarily.
The big question in this case is the one of dependencies.
Case 1
You have no dependencies you want to transform.
You can use single or multi-project setup and your compiler plugin.
Case 2
You have only open source Kotlin dependencies.
Download the source code, compile them with your plugin active and use the locally compiled code in your project.
This works. However, it will be harder and harder to maintain in the future as you have to recompile those dependencies every time they change. Not to mention you might have to recompile the whole dependency tree… it’s a mess.
Case 3
You have only Kotlin dependencies (might be closed source) and all your dependencies are compiled with the IR compiler.
You might be able to solve this in a general way, but it will be difficult. It also have the problem of maintenance and deeper dependencies as in Case 2.
Case 4
You have platform dependent dependencies like JS libraries with JavaScript source or JVM libraries with Java source (or Kotlin but not compiled with IR),
You cannot use the Kotlin compiler to solve this problem.
Conclusion
I would choose case 1 and avoid dependencies I want to transform.
The init
function
Also, there is one more thing to mention here.
Remember, that init
runs only when you create an instance of that class. For objects it is even more complex as they may be initialised lazily. So, for example you cannot count on the init
function to build up an object registry because anything you don’t touch won’t be in that registry.
It might be possible to solve your problem without a compiler plugin. It might be even better to do it without a compiler plugin.