How to implement a programming language compiler plugin?

I looked at the existing plugins for java, scala, but it’s completely incomprehensible how the source code is searched, the compiler is checked, the compiler is launched.
There are only trivial examples in the documentation.

I guess that is a too complex question for a simple forum post like here.

Such a task can reach from a simple task implementation using execOperations.exec to call some compile executable with arguments, to very fancy logic involving compile-avoidance if only non-ABI changes were done and so on.