square / workflow-kotlin

A Swift and Kotlin library for making composable state machines, and UIs driven by those state machines.
https://square.github.io/workflow
Apache License 2.0
1.02k stars 101 forks source link

Add Gradle logic to validate RequiresOptIn annotation dependencies and automatically opt-in our own code #407

Open zach-klippenstein opened 3 years ago

zach-klippenstein commented 3 years ago

Turns out that if you have RequiresOptIn annotations in a module and you depend on that module to annotate some code, the compiler will only validate opt-ins if the dependency on the annotations module is specified as apicompileOnly and implementation will cause the IDE to redline, but not the command line build, for some reason.

I recently wrote a plugin on an internal project (https://github.com/squareup/market/pull/1346) that validates this, as well as automatically adds the -Xopt-in= compiler flag to modules that use such annotations so you don't have to write @OptIn() on all your own code. We could either copy that, or we could open-source it and use it here.

I also filed an issue to generally move our custom logic to Gradle plugins as #406.

zach-klippenstein commented 3 years ago

Filed issues to Kotlin for these: