I have done this in the past by creating a new CompilerCommand instance to parse command line arguments and, more importantly, by extending the ever-scary Global class.
Overriding the computeInternalPhases method, you can use only some compiler steps (for example, before refchecks , use it only as an analyzer / typechecker), and you can add your own phases (plugins) as you expect. Of course, you can also fully generate class files.
So yes, it is definitely possible. In the end, the compiler itself also runs on the JVM.
source share