In a Maven build how do I configure Nullaway to exclude test classes? Right now it's firing on code that specifically checks that NullPointerExceptions are thrown in the right places.
The code to be excluded lives in the customary src/test/java directory but in the same packages as the model code.
NullAway is an Error Prone plugin. Error Prone works with the help of its own compiler (Maven compiler id
javac-with-errorprone). I see two ways you can avoid applying Error Prone/NullAway for test classes:If all relevant classes contain the
@Testannotation then you can use the-XepOpt:NullAway:ExcludedClassAnnotations=depends.on.junit.version.Testoption of the NullAway Maven plugin.Try to disable Error Prone by using the standard compiler when compiling Test classes by providing the standard compiler id (
<compilerId>javac</compilerId>) in the maven-compiler-plugin configuration for the goaltestCompile. See the accepted answer here for an example of how to provide a configuration for the test compilation.