|
115 | 115 | <groupId>org.apache.maven.plugins</groupId> |
116 | 116 | <artifactId>maven-compiler-plugin</artifactId> |
117 | 117 | <configuration> |
118 | | - <compilerArgs> |
| 118 | + <annotationProcessorPaths combine.children="append"/> |
| 119 | + <compilerArgs combine.children="append"> |
119 | 120 | <!-- |
120 | 121 | Disable warnings about modules. We cannot do much about some of these due to how Maven |
121 | 122 | works with modules with Surefire. |
|
214 | 215 | </pluginManagement> |
215 | 216 | </build> |
216 | 217 | </profile> |
| 218 | + |
| 219 | + <profile> |
| 220 | + <!-- ErrorProne only works with Java 21 and newer. If we're on Java 17, we cannot |
| 221 | + enable it within the compiler. This is somewhat unfortunate but should be okay |
| 222 | + as a workaround for now since we build on multiple JDKs on GitHub. --> |
| 223 | + <id>errorprone</id> |
| 224 | + <activation> |
| 225 | + <jdk>[21,)</jdk> |
| 226 | + </activation> |
| 227 | + |
| 228 | + <build> |
| 229 | + <plugins> |
| 230 | + <plugin> |
| 231 | + <groupId>org.apache.maven.plugins</groupId> |
| 232 | + <artifactId>maven-compiler-plugin</artifactId> |
| 233 | + |
| 234 | + <configuration> |
| 235 | + <annotationProcessorPaths> |
| 236 | + <annotationProcessorPath> |
| 237 | + <groupId>com.google.errorprone</groupId> |
| 238 | + <artifactId>error_prone_core</artifactId> |
| 239 | + <version>${errorprone.version}</version> |
| 240 | + </annotationProcessorPath> |
| 241 | + <annotationProcessorPath> |
| 242 | + <!-- Override what Maven is pulling in. This is fine during compilation as our |
| 243 | + code doesn't use Guava at all. This is needed for ErrorProne to not crash |
| 244 | + on startup. --> |
| 245 | + <groupId>com.google.guava</groupId> |
| 246 | + <artifactId>guava</artifactId> |
| 247 | + <version>[33,)</version> |
| 248 | + </annotationProcessorPath> |
| 249 | + <annotationProcessorPath> |
| 250 | + <groupId>com.uber.nullaway</groupId> |
| 251 | + <artifactId>nullaway</artifactId> |
| 252 | + <version>${nullaway.version}</version> |
| 253 | + </annotationProcessorPath> |
| 254 | + </annotationProcessorPaths> |
| 255 | + |
| 256 | + <compilerArgs> |
| 257 | + <!-- |
| 258 | + Disable warnings about modules. We cannot do much about some of these due to how Maven |
| 259 | + works with modules with Surefire. |
| 260 | + --> |
| 261 | + <arg>-Xlint:-module</arg> |
| 262 | + <!-- ErrorProne configuration --> |
| 263 | + <compilerArg>--should-stop=ifError=FLOW</compilerArg> |
| 264 | + <compilerArg> |
| 265 | + -Xplugin:ErrorProne |
| 266 | + -XepDisableWarningsInGeneratedCode |
| 267 | + -XepExcludedPaths:.*/target/generated.*?/.* |
| 268 | + -XepOpt:NullAway:AnnotatedPackages=io.github.ascopes.jct |
| 269 | + <!-- See https://github.com/uber/NullAway/issues/1319 --> |
| 270 | + -XepOpt:NullAway:ExcludedFieldAnnotations=org.junit.jupiter.*,org.mockito.* |
| 271 | + -XepOpt:NullAway:KnownInitializers=io.github.ascopes.jct.annotations.Initializer,io.github.ascopes.jct.junit.Managed |
| 272 | + </compilerArg> |
| 273 | + <!-- Needed for ErrorProne to be able to run --> |
| 274 | + <compilerArg>-XDaddTypeAnnotationsToSymbol=true</compilerArg> |
| 275 | + <compilerArg>-XDcompilePolicy=simple</compilerArg> |
| 276 | + </compilerArgs> |
| 277 | + </configuration> |
| 278 | + </plugin> |
| 279 | + </plugins> |
| 280 | + </build> |
| 281 | + </profile> |
217 | 282 | </profiles> |
218 | 283 | </project> |
0 commit comments