I just noticed that if you have a gradle module in your project that defines a custom
RequiresOptIn
annotation, and another module that depends on that module and annotates some code with the custom annotation, the Kotlin compiler won’t actually enforce the opt-in if the dependency on the module containing the annotation is specified as
implementation
or
compileOnly
– it must be an
api
dependency.
Even weirder, the IDE (Android Studio Arctic Fox) actually will still enforce the annotation with those other configurations – only command-line gradle builds don’t.
I haven’t seen any documentation about this requirement, and it doesn’t really make sense to me. Is this a gradle bug? A Kotlin bug? Kotlin gradle plugin bug? Or just expected behavior?
t
tapchicoma
04/13/2021, 5:18 PM
I think it will be better to open a new Kotlin issue