Created by: artem-zinnatullin
Original motivation was explained in discussion in Slack:
Hey guys, after spending couple days on trying to switch us to Buck upstream I came to conclusion that
kaptsupport needs to be changed in the upstream,kaptshould be optional.We have mixed Java/Kotlin modules where we deliberately run annotation processing only against Java sources (our reasoning is build speed & stability in both Buck and Gradle setups).
In our setup
kaptis not enabled on the Gradle sideOn the Buck side however
kaptkicks in even if we don't ask for it, what's worse it becomes primary method of annotation processing for mixed modules.We have 2 problems because of that:
If module doesn't have any
.ktwith annotations that need apt, build fails because.zipwith generated classes is not produced. Can be "solved" by converting one of the classes with annotations to Kotlin, but we don't need nor want that.Build will behave differently if we convert (see point №1) one of the classes to
.kt, it'll work in Buck but won't work in Gradle because we don't usekaptthereI've dealt with it before by turning
kaptoff in our fork, but we really want to get on to the upstream Buck to move faster, andkaptsupport is last huge blocker I'm dealing with…I think OkBuck could look for
kaptconfiguration and only then enablekaptin Buck
@cwoodwar6 mentioned they have same problem:
To your first point, we face the same issue and have been putting simple stub kotlin files to work around it. But we don’t like this solution either and have looking to fix it
Techincal aspects of this PR:
PR adds a separate annotation_processing_tool = "kapt/javac" to the DSL of Kotlin modules.
Default value is kept as kapt for compatibility.
Tools:
-
kapttool: Allows to run Java annotation processors against Kotlin sources while backporting it for Java sources too. -
javactool: Works only against Java sources, Kotlin sources won't have access to generated classes at compile time.
If this gets accepted, the next step will be to update OkBuck with respecting Gradle kapt vs annotationProcessor configurations.
cc @thalescm @cwoodwar6 @kageiit