Skip to content

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

Open
@zach-klippenstein

Description

@zach-klippenstein

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions