javamaven-compiler-pluginerrorprone

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


When maven-compiler-plugin:3.8.0:testCompile @ foo-child runs, thread dumps show errorprone is taking an extremely long time. I believe there is a bug with errorprone, but for now I'd rather just have errorprone not run on unit tests.

I have a parent pom.xml:

<modules>
  <module>foo-child</module>
</modules>
<dependencyManagement>
  <dependency>
    <groupId>com.google.errorprone</groupId>
    <artifactId>error_prone_annotations</artifactId>
  </dependency>
  // also has dependency for io.norberg auto-matter and com.google.auto.value auto-value
</dependencyManagement>
<build>
  <plugins>
     <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        // also has annotationProcessorPaths configuration for auto-matter and auto-value
     </plugin>
  </plugins>
</build>

Is there anything I can put in the foo-child pom.xml that will allow me to exclude maven-compiler-plugin:3.8.0:testCompile @ foo-child from being run at all.

I cannot exclude error prone completely because other things like guava depend on it.

EDIT: Seems like this user is trying to solve the same problem. Do you know how I could apply the solution given there to my case?


Solution

  • 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/.*