How to supress OptIn warnings in Gradle and during Git commit code analysis

I’m using OptIn features quite liberally in my code base. Because of this, I get a lot of warnings of the following form while compiling:

w: /path/to/file.kt: (73, 2): This class can only be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'

Is there a way to disable these warnings when compiling with Gradle? They tend to obscure relevant warnings when looking at the compile output.

The same goes for the code analysis warnings when I do a git commit. I like this feature when doing a commit, but since I have the @OptIn clause sin plenty of my files, it keeps telling me that there a warnings, which requires me to look at them individually and then reissue the commit.

I’d like to have a way to tell the compiler and code analyser to never warn me about the fact that I’m using the OptIn features.

1 Like