How to exclude error prone from being run on unit tests?

You can use the Inclusions and Exclusions of Tests plugin for this.


You can add the -XepExcludedPaths compiler option to your maven build.

https://errorprone.info/docs/flags


Use error prone's command line flag to disable checks: -XepDisableAllChecks

Similar answer for disabling error prone in bazel

add --javacopt="-XepDisableAllChecks" to your bazelrc

For specific test(s) use -XepExcludedPaths:

you can completely exclude certain paths from any Error Prone checking via the -XepExcludedPaths flag

-XepExcludedPaths:.*/build/generated/.*