Skip to content

Commit c4df56e

Browse files
authored
doc: Clarify and enhance GraalVmProcessor configuration example (#3786)
This update refines the `GraalVmProcessor` configuration example in response to feedback from #3755. The goal is to make the example more reliable and aligned with common Maven project setups. Key improvements include: * **Ensuring consistent parameter usage:** The example now adds `-Alog4j.graalvm.groupId` and `-Alog4j.graalvm.artifactId` to **all executions** of the Maven Compiler Plugin. This guarantees correct behavior regardless of the execution ID used in user projects. * **Simplifying plugin execution setup:** Instead of introducing a dedicated `generate-log4j-plugin-descriptor` execution, the example now modifies the existing `default-compile` execution. This reflects the most typical use case, where annotation processing and compilation occur together. These changes aim to make the setup easier to adopt while reducing configuration errors.
1 parent 3b0c77d commit c4df56e

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/site/antora/modules/ROOT/pages/manual/plugins.adoc

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ annotation processor creates such a file at compile-time.
211211
212212
[WARNING]
213213
====
214-
The `GraalVmProcessor` needs to know the `groupId` and `artifactId` coordinates of your project.
215-
These must be supplied to the processor using the `log4j.graalvm.groupId` and `log4j.graalvm.artifactId` annotation processor options.
214+
The `GraalVmProcessor` requires your project's `groupId` and `artifactId` to correctly generate the GraalVM reachability metadata file in the recommended location.
215+
Provide these values to the processor using the `log4j.graalvm.groupId` and `log4j.graalvm.artifactId` annotation processor options.
216216
====
217217
218218
You need to configure your build tool as follows to use both plugin processors:
@@ -227,15 +227,23 @@ Maven::
227227
<groupId>org.apache.maven.plugins</groupId>
228228
<artifactId>maven-compiler-plugin</artifactId>
229229
<version>${maven-compiler-plugin.version}</version>
230+
<configuration>
231+
<compilerArgs>
232+
<!-- Provide the project coordinates to `GraalVmProcessor`: -->
233+
<arg>-Alog4j.graalvm.groupId=${project.groupId}</arg>
234+
<arg>-Alog4j.graalvm.artifactId=${project.artifactId}</arg>
235+
</compilerArgs>
236+
</configuration>
230237
<executions>
231238
<execution>
232-
<id>generate-log4j-plugin-descriptor</id>
233-
<goals>
234-
<goal>compile</goal>
235-
</goals>
236-
<phase>process-classes</phase>
239+
<!--
240+
~ Explicitly list the annotation processors for the default compile execution.
241+
~ This is required starting with JDK 23, where annotation processors are not enabled automatically.
242+
~ Explicit configuration also improves build reliability and clarity.
243+
~ For more details, see: https://inside.java/2024/06/18/quality-heads-up/
244+
-->
245+
<id>default-compile</id>
237246
<configuration>
238-
<proc>only</proc>
239247
<annotationProcessorPaths>
240248
<!-- Include `log4j-core` providing
241249
1. `org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor` that generates `Log4j2Plugins.dat`
@@ -252,11 +260,6 @@ Maven::
252260
<!-- Process sources using `GraalVmProcessor` to generate a GraalVM reachability metadata file -->
253261
<processor>org.apache.logging.log4j.core.config.plugins.processor.GraalVmProcessor</processor>
254262
</annotationProcessors>
255-
<compilerArgs>
256-
<!-- Provide the project coordinates to `GraalVmProcessor`: -->
257-
<arg>-Alog4j.graalvm.groupId=${project.groupId}</arg>
258-
<arg>-Alog4j.graalvm.artifactId=${project.artifactId}</arg>
259-
</compilerArgs>
260263
</configuration>
261264
</execution>
262265
</executions>

0 commit comments

Comments
 (0)