lf215
lf215

Reputation: 959

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?

Upvotes: 11

Views: 5087

Answers (4)

Ori Marko
Ori Marko

Reputation: 58772

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

Upvotes: 5

daniu
daniu

Reputation: 14998

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

https://errorprone.info/docs/flags

Upvotes: 2

Rub
Rub

Reputation: 178

You can add maven profile to foo-child module which will run the build without errorprone. Also you can make the activation of that profile dependent from some parameter and set that parameter's value in parent pom.

Upvotes: 0

Anurag Singh
Anurag Singh

Reputation: 6200

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

Upvotes: 2

Related Questions