Skip to content

Commit 6141243

Browse files
authored
chore: remove Java 8 from v2 examples (#1531)
* Remove Java 8 issue #1466 * reverting pom to java 8 as change should only apply to examples * updated workflow to not build examples in java 8 workflow * updated syntax of workflow * excluding examples from spotbugs check for java 8 build * updated github actions workflow * updated workflows to have a comma seperated list of examples modules when java 8 to exclude * updating build syntax for non java 8 * updating gradle config for Java 11+ * updating the java version on spotbugs to 11
1 parent e7757c7 commit 6141243

File tree

22 files changed

+53
-223
lines changed

22 files changed

+53
-223
lines changed

.github/workflows/pr_build.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,17 @@ jobs:
6666
java-version: ${{ matrix.java }}
6767
cache: 'maven'
6868
- name: Build with Maven
69+
if: ${{ matrix.java == '8' }} # If 8 exclude the examples directory
70+
run: mvn -B install --file pom.xml -pl '!software.amazon.lambda.examples:powertools-examples-idempotency,!software.amazon.lambda.examples:powertools-examples-batch,!software.amazon.lambda.examples:powertools-examples-cloudformation,!software.amazon.lambda.examples:powertools-examples-core-utilities-cdk,!software.amazon.lambda.examples:powertools-examples-core-utilities-sam,!software.amazon.lambda.examples:powertools-examples-core-utilities-serverless,!software.amazon.lambda.examples:powertools-examples-core-utilities-terraform,!software.amazon.lambda.examples:powertools-examples-parameters,!software.amazon.lambda.examples:powertools-examples-serialization,!software.amazon.lambda.examples:powertools-examples-validation,!software.amazon.lambda.examples:cdk,!software.amazon.lambda:powertools-examples'
71+
- name: Build with Maven
72+
if: ${{ matrix.java != '8' }} # If not 8 don't exclude the examples directory
6973
run: mvn -B install --file pom.xml
7074
- name: Build Gradle Example - Java
71-
if: ${{ matrix.java == '8' }} # Gradle example can only be built on Java 8
75+
if: ${{ matrix.java != '8' }}
7276
working-directory: examples/powertools-examples-core-utilities/gradle
7377
run: ./gradlew build
7478
- name: Build Gradle Example - Kotlin
75-
if: ${{ matrix.java == '8' }} # Gradle example can only be built on Java 8
79+
if: ${{ matrix.java != '8' }}
7680
working-directory: examples/powertools-examples-core-utilities/kotlin
7781
run: ./gradlew build
7882
- name: Setup Terraform

.github/workflows/spotbugs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
2929
with:
3030
distribution: 'corretto'
31-
java-version: 8
31+
java-version: 11
3232
# https://github.com/jwgmeligmeyling/spotbugs-github-action/issues/6
3333
# https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/
3434
# Avoid complexity of git action with publishing report. Just build with spotbugs profile.

examples/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ If you're not using SAM, you can look for examples for other tools under [powert
6363

6464
You can find more examples in the https://github.com/aws/aws-sam-cli-app-templates project:
6565

66-
* [Java 8 + Maven](https://github.com/aws/aws-sam-cli-app-templates/tree/master/java8/hello-pt-maven)
67-
* [Java 8 on Amazon Linux 2 + Maven](https://github.com/aws/aws-sam-cli-app-templates/tree/master/java8.al2/hello-pt-maven)
6866
* [Java 11 + Maven](https://github.com/aws/aws-sam-cli-app-templates/tree/master/java11/hello-pt-maven)
6967
* [Java 17 + Maven](https://github.com/aws/aws-sam-cli-app-templates/tree/master/java17/hello-pt-maven)
7068
* [Java 17 + Gradle](https://github.com/aws/aws-sam-cli-app-templates/tree/master/java17/hello-pt-gradle)

examples/powertools-examples-batch/pom.xml

+2-23
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
<properties>
1414
<log4j.version>2.20.0</log4j.version>
15-
<maven.compiler.source>1.8</maven.compiler.source>
16-
<maven.compiler.target>1.8</maven.compiler.target>
15+
<maven.compiler.source>11</maven.compiler.source>
16+
<maven.compiler.target>11</maven.compiler.target>
1717
<aspectj.version>1.9.20</aspectj.version>
1818
<sdk.version>2.21.1</sdk.version>
1919
</properties>
@@ -143,25 +143,4 @@
143143
</plugin>
144144
</plugins>
145145
</build>
146-
<profiles>
147-
<!-- Use a profile to enforce AspectJ version 1.9.7 if we are Java 1.8 otherwise we'll get class
148-
version mismatch issues. All subsequent Java releases build with the default AspectJ configuration
149-
on the project.
150-
151-
Note:
152-
- if you are running Java > 1.8, you can remove this profile altogether
153-
- If you are running on Java 1.8, you should apply the aspectJ version here to the project, and remove
154-
the profile.
155-
-->
156-
157-
<profile>
158-
<id>jdk8</id>
159-
<activation>
160-
<jdk>(,11)</jdk> <!-- 8 -->
161-
</activation>
162-
<properties>
163-
<aspectj.version>1.9.7</aspectj.version>
164-
</properties>
165-
</profile>
166-
</profiles>
167146
</project>

examples/powertools-examples-cloudformation/README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,27 @@
22

33
This project contains an example of Lambda function using the CloudFormation module of Powertools for AWS Lambda in Java. For more information on this module, please refer to the [documentation](https://awslabs.github.io/aws-lambda-powertools-java/utilities/custom_resources/).
44

5+
In this example you pass in a bucket name as a parameter and upon CloudFormation events a call is made to a lambda. That lambda attempts to create the bucket on CREATE events, create a new bucket if the name changes with an UPDATE event and delete the bucket upon DELETE events.
6+
57
## Deploy the sample application
68

79
This sample can be used either with the Serverless Application Model (SAM) or with CDK.
810

911
### Deploy with SAM CLI
1012
To deploy it using the SAM CLI, check out the instructions for getting started in [the examples directory](../README.md)
13+
Run the following in your shell:
14+
15+
```bash
16+
cd infra/sam
17+
sam build
18+
sam deploy --guided --parameter-overrides BucketNameParam=my-unique-bucket-20230718
19+
```
1120

1221
### Deploy with CDK
1322
To use CDK you need the following tools.
1423

1524
* CDK - [Install CDK](https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html)
16-
* Java 8 - [Install Java 8](https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/downloads-list.html)
25+
* Java 11 - [Install Java 11](https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/downloads-list.html)
1726
* Maven - [Install Maven](https://maven.apache.org/install.html)
1827
* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community)
1928

examples/powertools-examples-cloudformation/pom.xml

+2-22
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
<properties>
1313
<log4j.version>2.20.0</log4j.version>
14-
<maven.compiler.source>1.8</maven.compiler.source>
15-
<maven.compiler.target>1.8</maven.compiler.target>
14+
<maven.compiler.source>11</maven.compiler.source>
15+
<maven.compiler.target>11</maven.compiler.target>
1616
<lambda.core.version>1.2.3</lambda.core.version>
1717
<lambda.events.version>3.11.3</lambda.events.version>
1818
<aws.sdk.version>2.21.0</aws.sdk.version>
@@ -169,24 +169,4 @@
169169
</plugin>
170170
</plugins>
171171
</build>
172-
<profiles>
173-
<!-- Use a profile to enforce AspectJ version 1.9.7 if we are Java 1.8 otherwise we'll get class
174-
version mismatch issues. All subsequent Java releases build with the default AspectJ configuration
175-
on the project.
176-
177-
Note:
178-
- if you are running Java > 1.8, you can remove this profile altogether
179-
- If you are running on Java 1.8, you should apply the aspectJ version here to the project, and remove
180-
the profile.
181-
-->
182-
<profile>
183-
<id>jdk8</id>
184-
<activation>
185-
<jdk>(,11)</jdk> <!-- 8 -->
186-
</activation>
187-
<properties>
188-
<aspectj.version>1.9.7</aspectj.version>
189-
</properties>
190-
</profile>
191-
</profiles>
192172
</project>

examples/powertools-examples-core-utilities/cdk/app/pom.xml

+2-22
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
<properties>
1414
<log4j.version>2.20.0</log4j.version>
15-
<maven.compiler.source>1.8</maven.compiler.source>
16-
<maven.compiler.target>1.8</maven.compiler.target>
15+
<maven.compiler.source>11</maven.compiler.source>
16+
<maven.compiler.target>11</maven.compiler.target>
1717
<aspectj.version>1.9.20</aspectj.version>
1818
</properties>
1919

@@ -138,24 +138,4 @@
138138
</plugin>
139139
</plugins>
140140
</build>
141-
<profiles>
142-
<!-- Use a profile to enforce AspectJ version 1.9.7 if we are Java 1.8 otherwise we'll get class
143-
version mismatch issues. All subsequent Java releases build with the default AspectJ configuration
144-
on the project.
145-
146-
Note:
147-
- if you are running Java > 1.8, you can remove this profile altogether
148-
- If you are running on Java 1.8, you should apply the aspectJ version here to the project, and remove
149-
the profile.
150-
-->
151-
<profile>
152-
<id>jdk8</id>
153-
<activation>
154-
<jdk>(,11)</jdk> <!-- 8 -->
155-
</activation>
156-
<properties>
157-
<aspectj.version>1.9.7</aspectj.version>
158-
</properties>
159-
</profile>
160-
</profiles>
161141
</project>

examples/powertools-examples-core-utilities/cdk/infra/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
<artifactId>maven-compiler-plugin</artifactId>
1919
<version>3.11.0</version>
2020
<configuration>
21-
<source>1.8</source>
22-
<target>1.8</target>
21+
<source>11</source>
22+
<target>11</target>
2323
</configuration>
2424
</plugin>
2525
<plugin>

examples/powertools-examples-core-utilities/gradle/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Powertools for AWS Lambda (Java) - Core Utilities Example with Gradle
22

33
This project demonstrates the Lambda for Powertools Java module deployed using [Serverless Application Model](https://aws.amazon.com/serverless/sam/) with
4-
[Gradle](https://gradle.org/) running the build. This example is configured for Java 1.8 only; in order to use a newer version, check out the Gradle
4+
[Gradle](https://gradle.org/) running the build. This example is configured for Java 11 only; in order to use a newer version, check out the Gradle
55
configuration guide [in the main project README](../../../README.md).
66

77
You can also use `sam init` to create a new Gradle-powered Powertools application - choose to use the **AWS Quick Start Templates**,

examples/powertools-examples-core-utilities/gradle/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11

22
plugins {
33
id 'java'
4-
id "io.freefair.aspectj.post-compile-weaving" version "6.6.3"
4+
id "io.freefair.aspectj.post-compile-weaving" version "8.2.2"
55
}
66

77
wrapper {
8-
gradleVersion = "7.6.1"
8+
gradleVersion = "8.5"
99
}
1010

1111
compileJava {
12-
sourceCompatibility = "1.8"
13-
targetCompatibility = "1.8"
12+
sourceCompatibility = "11"
13+
targetCompatibility = "11"
1414

1515
ajc {
1616
enabled = true

examples/powertools-examples-core-utilities/gradle/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

examples/powertools-examples-core-utilities/gradle/template.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Resources:
2626
Properties:
2727
CodeUri: .
2828
Handler: helloworld.App::handleRequest
29-
Runtime: java8
29+
Runtime: java11
3030
MemorySize: 512
3131
Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
3232
Variables:
@@ -43,7 +43,7 @@ Resources:
4343
Properties:
4444
CodeUri: .
4545
Handler: helloworld.AppStream::handleRequest
46-
Runtime: java8
46+
Runtime: java11
4747
MemorySize: 512
4848
Tracing: Active
4949
Environment:

examples/powertools-examples-core-utilities/kotlin/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Powertools for AWS Lambda (Kotlin) - Core Utilities Example
22

33
This project demonstrates the Lambda for Powertools Kotlin module deployed using [Serverless Application Model](https://aws.amazon.com/serverless/sam/) with
4-
[Gradle](https://gradle.org/) running the build. This example is configured for Java 1.8 only; in order to use a newer version, check out the Gradle
4+
[Gradle](https://gradle.org/) running the build. This example is configured for Java 11 only; in order to use a newer version, check out the Gradle
55
configuration guide [in the main project README](../../../README.md).
66

77
You can also use `sam init` to create a new Gradle-powered Powertools application - choose to use the **AWS Quick Start Templates**,
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id("io.freefair.aspectj.post-compile-weaving") version "6.6.3"
2+
id("io.freefair.aspectj.post-compile-weaving") version "8.2.2"
33
kotlin("jvm") version "1.9.10"
44
}
55

@@ -21,19 +21,6 @@ dependencies {
2121
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
2222
}
2323

24-
tasks.compileKotlin {
25-
kotlinOptions {
26-
jvmTarget = "1.8"
27-
}
28-
}
29-
30-
tasks.compileTestKotlin {
31-
kotlinOptions {
32-
jvmTarget = "1.8"
33-
}
34-
}
35-
36-
// If using JDK 11 or higher, use the following instead:
37-
//kotlin {
38-
// jvmToolchain(11)
39-
//}
24+
kotlin {
25+
jvmToolchain(11)
26+
}

examples/powertools-examples-core-utilities/kotlin/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

examples/powertools-examples-core-utilities/sam/pom.xml

+2-22
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
<properties>
1212
<log4j.version>2.20.0</log4j.version>
13-
<maven.compiler.source>1.8</maven.compiler.source>
14-
<maven.compiler.target>1.8</maven.compiler.target>
13+
<maven.compiler.source>11</maven.compiler.source>
14+
<maven.compiler.target>11</maven.compiler.target>
1515
<aspectj.version>1.9.20</aspectj.version>
1616
</properties>
1717

@@ -126,24 +126,4 @@
126126
</plugin>
127127
</plugins>
128128
</build>
129-
<profiles>
130-
<!-- Use a profile to enforce AspectJ version 1.9.7 if we are Java 1.8 otherwise we'll get class
131-
version mismatch issues. All subsequent Java releases build with the default AspectJ configuration
132-
on the project.
133-
134-
Note:
135-
- if you are running Java > 1.8, you can remove this profile altogether
136-
- If you are running on Java 1.8, you should apply the aspectJ version here to the project, and remove
137-
the profile.
138-
-->
139-
<profile>
140-
<id>jdk8</id>
141-
<activation>
142-
<jdk>(,11)</jdk> <!-- 8 -->
143-
</activation>
144-
<properties>
145-
<aspectj.version>1.9.7</aspectj.version>
146-
</properties>
147-
</profile>
148-
</profiles>
149129
</project>

examples/powertools-examples-core-utilities/serverless/pom.xml

+3-22
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
<properties>
1212
<log4j.version>2.20.0</log4j.version>
13-
<maven.compiler.source>1.8</maven.compiler.source>
14-
<maven.compiler.target>1.8</maven.compiler.target>
13+
<maven.compiler.source>11</maven.compiler.source>
14+
<maven.compiler.target>11</maven.compiler.target>
1515
<aspectj.version>1.9.20</aspectj.version>
1616
</properties>
1717

@@ -59,6 +59,7 @@
5959
</dependencies>
6060

6161
<build>
62+
<finalName>helloworld-lambda</finalName>
6263
<plugins>
6364
<plugin>
6465
<groupId>dev.aspectj</groupId>
@@ -126,24 +127,4 @@
126127
</plugin>
127128
</plugins>
128129
</build>
129-
<profiles>
130-
<!-- Use a profile to enforce AspectJ version 1.9.7 if we are Java 1.8 otherwise we'll get class
131-
version mismatch issues. All subsequent Java releases build with the default AspectJ configuration
132-
on the project.
133-
134-
Note:
135-
- if you are running Java > 1.8, you can remove this profile altogether
136-
- If you are running on Java 1.8, you should apply the aspectJ version here to the project, and remove
137-
the profile.
138-
-->
139-
<profile>
140-
<id>jdk8</id>
141-
<activation>
142-
<jdk>(,11)</jdk> <!-- 8 -->
143-
</activation>
144-
<properties>
145-
<aspectj.version>1.9.7</aspectj.version>
146-
</properties>
147-
</profile>
148-
</profiles>
149130
</project>

0 commit comments

Comments
 (0)