@lukaville Unfortunately this is all undocumented and this wisdom seems to be mostly passed on through word of mouth; I don't know of any good article that summarizes it. My advice would be to look at discussions on github issues of projects like the Kotlin Gradle Plugin or Buck build system. Sometimes you get lucky and a JB employee left a helpful comment. For a very high level overview you can also look at my kotlin-compile-testing libary which implements a simple build process with Java sources and annotation processors:
https://github.com/tschuchortdev/kotlin-compile-testing/blob/master/src/main/kotlin/com/tschuchort/compiletesting/KotlinCompilation.kt Basically the build process is divided into 4 steps:
1. Generate stubs: The Kotlin compiler generates Java stub files which is like a Kotlin-to-Java source-to-source translation except that all the methods are empty (since the annotation processor doesn't care about that)
2. Run KAPT: The KAPT plugin is run which runs Java's APT tool internally (this is why the stub files are needed: APT only understands Java)
3. Compile Kotlin: K2JVMCompiler is run to compile only Kotlin sources. I think it actually does some compilation of Java sources internally, possibly by reusing Javac logic. Otherwise you wouldn't be able to reference Java classes in Kotlin
4. Compile Java: The remaining Java files are compiled regularly using Javac with already compiled Kotlin classes on the classpath. No annotation processing is done.
Keep in mind that compiler internals are changing constantly and also heavily depend on the compiler flags. For example you can (theoretically) skip some of the steps by including certain compiler flags that may or may not be broken at any time.