The problem here is simple: The Kotlin plugin authors decided that Kotlin should be compiled before Java. The Groovy plugin on the other hand makes the opposite assumption.
You can try overriding the Kotlin plugin’s behavior by doing:
compileJava.dependsOn = compileJava.taskDependencies.values - compileKotlin
compileKotlin.dependsOn(compileGroovy)