Use the new `generatedKotlin` API in Kotlin 2.3 https://kotlinlang.org/docs/whatsnew-eap.html#new-api-for-registering-generated-sources-in-gradle-projects It is experimental, so maybe have optional support for now?