Skip to content

Commit 0abf6d7

Browse files
build(log4j2): Pin compilation to JDK 8 via Maven Toolchains (#616)
Release 1.6.3 was built on a JDK that does not run annotation processors by default, which silently dropped the Log4j2 plugin descriptor (META-INF/.../Log4j2Plugins.dat) for LambdaAppender, LambdaTextFormat, and LambdaJsonFormat. The published artifact was broken at runtime: log4j could not resolve <Lambda>, <LambdaTextFormat>, or <LambdaJsonFormat> elements in user log4j2.xml configurations. Configure maven-toolchains-plugin to require a JDK 8 toolchain so javac comes from a JDK that runs annotation processors by default, regardless of which JVM Maven is invoked under. The version range [1.8,9) matches both "1.8" and "8". The existing GitHub Actions workflow at .github/workflows/aws-lambda-java-log4j2.yml uses actions/setup-java@v5 with java-version: 8 and distribution: corretto. setup-java@v5 auto-generates a ~/.m2/toolchains.xml entry with <version>8</version>, which the [1.8,9) range matches, so no workflow changes are required. When no matching JDK 8 toolchain is available, the build now fails fast at the validate phase with a clear "Cannot find matching toolchain definitions" error instead of silently producing an artifact missing its plugin descriptor. Co-authored-by: Davide Melfi <darklight3it@gmail.com>
1 parent 2714c2c commit 0abf6d7

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

aws-lambda-java-log4j2/pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,26 @@
7979
<plugins>
8080
<plugin>
8181
<groupId>org.apache.maven.plugins</groupId>
82+
<artifactId>maven-toolchains-plugin</artifactId>
83+
<version>3.2.0</version>
84+
<configuration>
85+
<toolchains>
86+
<jdk>
87+
<!-- Range matches both "8" (e.g. actions/setup-java)
88+
and "1.8" (legacy / hand-written toolchains). -->
89+
<version>[1.8,9)</version>
90+
</jdk>
91+
</toolchains>
92+
</configuration>
93+
<executions>
94+
<execution>
95+
<goals>
96+
<goal>toolchain</goal>
97+
</goals>
98+
</execution>
99+
</executions>
100+
</plugin>
101+
<plugin>
82102
<artifactId>maven-surefire-plugin</artifactId>
83103
<version>3.5.2</version>
84104
</plugin>

0 commit comments

Comments
 (0)