Skip to content

Commit

Permalink
Add a note about other annotation processors to the maven example
Browse files Browse the repository at this point in the history
Fixes #1187

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=311831016
  • Loading branch information
RichardBradley authored and kluever committed May 17, 2020
1 parent 1341c4e commit cedd31c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
<artifactId>error_prone_core</artifactId>
<version>2.3.5-SNAPSHOT</version>
</path>
<!-- Add any other annotation processors here,

This comment has been minimized.

Copy link
@mirabilos

mirabilos Jun 15, 2020

This still breaks auto-discovery of annotation processors, especially when handed down from parent POMs. I ran into this when trying to add hibernate-validator-annotation-processor to a build that also used Lombok.

The only reliable way to get possibly-multiple possibly-handed-down annotation processors working in a Maven project is to add them as dependency in scope provided:

-                                               <annotationProcessorPaths>
-                                                       <path>
-                                                               <groupId>org.hibernate.validator</groupId>
-                                                               <artifactId>hibernate-validator-annotation-processor</artifactId>
-                                                               <version>${hibernate.validator.version}</version>
-                                                       </path>
-                                               </annotationProcessorPaths>

+                               <dependency>
+                                       <groupId>org.hibernate.validator</groupId>
+                                       <artifactId>hibernate-validator-annotation-processor</artifactId>
+                                       <version>${hibernate.validator.version}</version>
+                                       <scope>provided</scope>
+                               </dependency>

Please support that here as well, so error-prone can be used by more projects.

This comment has been minimized.

Copy link
@tbroyer

tbroyer Jun 15, 2020

Contributor

You'll want to use combine.children="append", you can even use it in the parent POM: https://maven.apache.org/pom.html#plugins

In the parent POM:

<annotationProcessorPaths combine.children="append">
    <path>
        <groupId>com.google.errorprone</groupId>
        <artifactId>error_prone_core</artifactId>
        <version>2.4.0</version>
    </path>
</annotationProcessorPaths>

and in the submodule POM:

<annotationProcessorPaths>
    <path>
        <groupId>org.hibernate.validator</groupId>
        <artifactId>hibernate-validator-annotation-processor</artifactId>
        <version>${hibernate.validator.version}</version>
    </path>
</annotationProcessorPaths>

and you'll get both error_prone_core and hibernate-validator-annotation-processor in your processor path.

This comment has been minimized.

Copy link
@mirabilos

mirabilos via email Jun 15, 2020

even if they are also on the project dependency classpath. -->
</annotationProcessorPaths>
</configuration>
</plugin>
Expand Down

0 comments on commit cedd31c

Please sign in to comment.