Skip to content

Commit 8b24237

Browse files
authored
build: fix building in IntelliJ IDEA (#200)
For an improved supply chain security (see [XDev for example](https://xdev.software/en/news/detail/discovering-the-perfect-java-supply-chain-attack-vector-and-how-it-got-fixed) automatic annotation processor discovery should be disabled and annotation processors should be explicitly listed on the command line. In Maven this can be done: - If the list of processors is not empty, by adding an `<annotationProcessors>` configuration element. - If the list of processors is empty, the above setting will cause an invalid `-processor ''` argument to be passed to the compiler. To fix that `-proc:none` needs to be provided. The above procedure breaks IntelliJ IDEA compilation, since seeing a `-proc:none` not only disables annotation processing, but also causes IDEA to ignore the provided `--processor-path`. We don't have annotation processors, but we have a [compiler `Plugin`](https://docs.oracle.com/javase/8/docs/jdk/api/javac/tree/com/sun/source/util/Plugin.html), which needs to be on the annotation processor path. This PR solves these compatibility problems, by removing both the `-proc:none` and `-processor` arguments and _de facto_ **enables** the automatic discovery of annotation processors. It adds a comment to re-enable the `annotationProcessor` element if an annotation processor is added in the future. Closes #199
1 parent 13d5673 commit 8b24237

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

pom.xml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,18 +236,18 @@
236236
<arg>-XDcompilePolicy=simple</arg>
237237
<arg>--should-stop=ifError=FLOW</arg>
238238
<arg>-Xplugin:ErrorProne</arg>
239-
<!-- No annotation processors for now -->
240-
<arg>-proc:none</arg>
239+
<!--
240+
~ Due to a bug in IntelliJ IDEA, annotation processing MUST be enabled.
241+
~ Failing to do so will cause IDEA to ignore the annotation processor path
242+
~ and choke on the Error Prone compiler arguments.
243+
~
244+
~ On the other hand, we cannot pass an empty `annotationProcessors` list to Maven,
245+
~ since the `-processor` compiler argument requires at least one processor class name.
246+
~
247+
~ If you add an annotation processor, please also add an `annotationProcessors` configuration
248+
~ option.
249+
-->
241250
</compilerArgs>
242-
<!--
243-
~ Due to the changes to annotation processor policy in JDK 23, all annotation processors
244-
~ should be mentioned explicitly.
245-
~ To add an annotation processor, add it to `annotationProcessors` below and remove
246-
~ `-proc:none` above.
247-
~
248-
~ See: https://inside.java/2024/06/18/quality-heads-up/
249-
-->
250-
<annotationProcessors/>
251251
<annotationProcessorPaths>
252252
<path>
253253
<groupId>com.google.errorprone</groupId>

0 commit comments

Comments
 (0)