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 api – compileOnly 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.
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 asapi
–compileOnly
andimplementation
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.