Skip to content

Commit 69b9b2b

Browse files
authored
Merge pull request #617 from aws/dmelfi/pinning-java-8-version-via-toolchain
Pin compilation to JDK8 via Maven Toolchains
2 parents ba130c1 + d539586 commit 69b9b2b

9 files changed

Lines changed: 194 additions & 1 deletion

File tree

CONTRIBUTING.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,25 @@ To send us a pull request, please:
3636
5. Send us a pull request, answering any default questions in the pull request interface.
3737
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
3838

39+
40+
## Build Prerequisites
41+
42+
This project uses the Maven Toolchains Plugin to pin compilation to JDK 8. If you don't have a `~/.m2/toolchains.xml` configured, builds will fail with:
43+
44+
```
45+
No toolchain found for type jdk [ version='[1.8,9)' ]
46+
```
47+
48+
To fix this, copy the example file to your Maven config directory and update the path:
49+
50+
```bash
51+
cp toolchains.xml.example ~/.m2/toolchains.xml
52+
```
53+
54+
Then edit `~/.m2/toolchains.xml` and set `<jdkHome>` to your local JDK 8 installation path.
55+
56+
Note: if you use `actions/setup-java` in CI (as our GitHub Actions workflows do), this file is generated automatically.
57+
3958
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
4059
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
4160

aws-lambda-java-core/pom.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,32 @@
3636
<maven.compiler.target>1.8</maven.compiler.target>
3737
</properties>
3838

39+
<build>
40+
<plugins>
41+
<plugin>
42+
<groupId>org.apache.maven.plugins</groupId>
43+
<artifactId>maven-toolchains-plugin</artifactId>
44+
<version>3.2.0</version>
45+
<configuration>
46+
<toolchains>
47+
<jdk>
48+
<!-- Range matches both "8" (e.g. actions/setup-java)
49+
and "1.8" (legacy / hand-written toolchains). -->
50+
<version>[1.8,9)</version>
51+
</jdk>
52+
</toolchains>
53+
</configuration>
54+
<executions>
55+
<execution>
56+
<goals>
57+
<goal>toolchain</goal>
58+
</goals>
59+
</execution>
60+
</executions>
61+
</plugin>
62+
</plugins>
63+
</build>
64+
3965
<profiles>
4066
<profile>
4167
<id>dev</id>

aws-lambda-java-events-sdk-transformer/pom.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,27 @@
7979

8080
<build>
8181
<plugins>
82+
<plugin>
83+
<groupId>org.apache.maven.plugins</groupId>
84+
<artifactId>maven-toolchains-plugin</artifactId>
85+
<version>3.2.0</version>
86+
<configuration>
87+
<toolchains>
88+
<jdk>
89+
<!-- Range matches both "8" (e.g. actions/setup-java)
90+
and "1.8" (legacy / hand-written toolchains). -->
91+
<version>[1.8,9)</version>
92+
</jdk>
93+
</toolchains>
94+
</configuration>
95+
<executions>
96+
<execution>
97+
<goals>
98+
<goal>toolchain</goal>
99+
</goals>
100+
</execution>
101+
</executions>
102+
</plugin>
82103
<plugin>
83104
<artifactId>maven-surefire-plugin</artifactId>
84105
<version>${maven-surefire-plugin.version}</version>

aws-lambda-java-events/pom.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,32 @@
4242
<junit-jupiter.version>5.12.2</junit-jupiter.version>
4343
</properties>
4444

45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-toolchains-plugin</artifactId>
50+
<version>3.2.0</version>
51+
<configuration>
52+
<toolchains>
53+
<jdk>
54+
<!-- Range matches both "8" (e.g. actions/setup-java)
55+
and "1.8" (legacy / hand-written toolchains). -->
56+
<version>[1.8,9)</version>
57+
</jdk>
58+
</toolchains>
59+
</configuration>
60+
<executions>
61+
<execution>
62+
<goals>
63+
<goal>toolchain</goal>
64+
</goals>
65+
</execution>
66+
</executions>
67+
</plugin>
68+
</plugins>
69+
</build>
70+
4571
<distributionManagement>
4672
<repository>
4773
<id>sonatype-nexus-staging</id>

aws-lambda-java-runtime-interface-client/pom.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,27 @@
115115
</extension>
116116
</extensions>
117117
<plugins>
118+
<plugin>
119+
<groupId>org.apache.maven.plugins</groupId>
120+
<artifactId>maven-toolchains-plugin</artifactId>
121+
<version>3.2.0</version>
122+
<configuration>
123+
<toolchains>
124+
<jdk>
125+
<!-- Range matches both "8" (e.g. actions/setup-java)
126+
and "1.8" (legacy / hand-written toolchains). -->
127+
<version>[1.8,9)</version>
128+
</jdk>
129+
</toolchains>
130+
</configuration>
131+
<executions>
132+
<execution>
133+
<goals>
134+
<goal>toolchain</goal>
135+
</goals>
136+
</execution>
137+
</executions>
138+
</plugin>
118139
<plugin>
119140
<artifactId>maven-install-plugin</artifactId>
120141
<groupId>org.apache.maven.plugins</groupId>

aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/Dockerfile.agent

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,21 @@ COPY --from=docker/buildx-bin:latest /buildx /usr/libexec/docker/cli-plugins/doc
1111
ENV PATH="$PATH:/apache-maven/bin"
1212
RUN mkdir /apache-maven && \
1313
curl https://archive.apache.org/dist/maven/maven-3/3.8.7/binaries/apache-maven-3.8.7-bin.tar.gz | \
14-
tar -xz -C /apache-maven --strip-components 1
14+
tar -xz -C /apache-maven --strip-components 1
15+
16+
# Declare JDK 8 in toolchains.xml so maven-toolchains-plugin can resolve it
17+
RUN mkdir -p /root/.m2 && \
18+
cat > /root/.m2/toolchains.xml <<EOF
19+
<?xml version="1.0" encoding="UTF-8"?>
20+
<toolchains>
21+
<toolchain>
22+
<type>jdk</type>
23+
<provides>
24+
<version>8</version>
25+
</provides>
26+
<configuration>
27+
<jdkHome>${JAVA_HOME}</jdkHome>
28+
</configuration>
29+
</toolchain>
30+
</toolchains>
31+
EOF

aws-lambda-java-serialization/pom.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,27 @@
191191
</extension>
192192
</extensions>
193193
<plugins>
194+
<plugin>
195+
<groupId>org.apache.maven.plugins</groupId>
196+
<artifactId>maven-toolchains-plugin</artifactId>
197+
<version>3.2.0</version>
198+
<configuration>
199+
<toolchains>
200+
<jdk>
201+
<!-- Range matches both "8" (e.g. actions/setup-java)
202+
and "1.8" (legacy / hand-written toolchains). -->
203+
<version>[1.8,9)</version>
204+
</jdk>
205+
</toolchains>
206+
</configuration>
207+
<executions>
208+
<execution>
209+
<goals>
210+
<goal>toolchain</goal>
211+
</goals>
212+
</execution>
213+
</executions>
214+
</plugin>
194215
<plugin>
195216
<groupId>org.apache.maven.plugins</groupId>
196217
<artifactId>maven-shade-plugin</artifactId>

aws-lambda-java-tests/pom.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,27 @@
245245

246246
<build>
247247
<plugins>
248+
<plugin>
249+
<groupId>org.apache.maven.plugins</groupId>
250+
<artifactId>maven-toolchains-plugin</artifactId>
251+
<version>3.2.0</version>
252+
<configuration>
253+
<toolchains>
254+
<jdk>
255+
<!-- Range matches both "8" (e.g. actions/setup-java)
256+
and "1.8" (legacy / hand-written toolchains). -->
257+
<version>[1.8,9)</version>
258+
</jdk>
259+
</toolchains>
260+
</configuration>
261+
<executions>
262+
<execution>
263+
<goals>
264+
<goal>toolchain</goal>
265+
</goals>
266+
</execution>
267+
</executions>
268+
</plugin>
248269
<plugin>
249270
<groupId>org.apache.maven.plugins</groupId>
250271
<artifactId>maven-compiler-plugin</artifactId>

toolchains.xml.example

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Maven Toolchains configuration for aws-lambda-java-libs.
4+
5+
This file tells Maven where to find JDK 8, which is required by the
6+
maven-toolchains-plugin configured in each module's pom.xml.
7+
8+
To use: copy this file to ~/.m2/toolchains.xml and set the jdkHome
9+
path to match your local JDK 8 installation.
10+
-->
11+
<toolchains>
12+
<toolchain>
13+
<type>jdk</type>
14+
<provides>
15+
<version>8</version>
16+
</provides>
17+
<configuration>
18+
<jdkHome>/path/to/your/jdk8</jdkHome>
19+
</configuration>
20+
</toolchain>
21+
</toolchains>

0 commit comments

Comments
 (0)