Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove Java 8 from v2 examples #1531

Merged
merged 10 commits into from
Dec 1, 2023
8 changes: 6 additions & 2 deletions .github/workflows/pr_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,17 @@ jobs:
java-version: ${{ matrix.java }}
cache: 'maven'
- name: Build with Maven
if: ${{ matrix.java == '8' }} # If 8 exclude the examples directory
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'
- name: Build with Maven
if: ${{ matrix.java != '8' }} # If not 8 don't exclude the examples directory
run: mvn -B install --file pom.xml
- name: Build Gradle Example - Java
if: ${{ matrix.java == '8' }} # Gradle example can only be built on Java 8
if: ${{ matrix.java != '8' }}
working-directory: examples/powertools-examples-core-utilities/gradle
run: ./gradlew build
- name: Build Gradle Example - Kotlin
if: ${{ matrix.java == '8' }} # Gradle example can only be built on Java 8
if: ${{ matrix.java != '8' }}
working-directory: examples/powertools-examples-core-utilities/kotlin
run: ./gradlew build
- name: Setup Terraform
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spotbugs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
with:
distribution: 'corretto'
java-version: 8
java-version: 11
# https://github.com/jwgmeligmeyling/spotbugs-github-action/issues/6
# https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/
# Avoid complexity of git action with publishing report. Just build with spotbugs profile.
Expand Down
2 changes: 0 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ If you're not using SAM, you can look for examples for other tools under [powert

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

* [Java 8 + Maven](https://github.com/aws/aws-sam-cli-app-templates/tree/master/java8/hello-pt-maven)
* [Java 8 on Amazon Linux 2 + Maven](https://github.com/aws/aws-sam-cli-app-templates/tree/master/java8.al2/hello-pt-maven)
* [Java 11 + Maven](https://github.com/aws/aws-sam-cli-app-templates/tree/master/java11/hello-pt-maven)
* [Java 17 + Maven](https://github.com/aws/aws-sam-cli-app-templates/tree/master/java17/hello-pt-maven)
* [Java 17 + Gradle](https://github.com/aws/aws-sam-cli-app-templates/tree/master/java17/hello-pt-gradle)
Expand Down
25 changes: 2 additions & 23 deletions examples/powertools-examples-batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

<properties>
<log4j.version>2.20.0</log4j.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<aspectj.version>1.9.20</aspectj.version>
<sdk.version>2.21.1</sdk.version>
</properties>
Expand Down Expand Up @@ -143,25 +143,4 @@
</plugin>
</plugins>
</build>
<profiles>
<!-- Use a profile to enforce AspectJ version 1.9.7 if we are Java 1.8 otherwise we'll get class
version mismatch issues. All subsequent Java releases build with the default AspectJ configuration
on the project.

Note:
- if you are running Java > 1.8, you can remove this profile altogether
- If you are running on Java 1.8, you should apply the aspectJ version here to the project, and remove
the profile.
-->

<profile>
<id>jdk8</id>
<activation>
<jdk>(,11)</jdk> <!-- 8 -->
</activation>
<properties>
<aspectj.version>1.9.7</aspectj.version>
</properties>
</profile>
</profiles>
</project>
11 changes: 10 additions & 1 deletion examples/powertools-examples-cloudformation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,27 @@

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/).

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.

## Deploy the sample application

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

### Deploy with SAM CLI
To deploy it using the SAM CLI, check out the instructions for getting started in [the examples directory](../README.md)
Run the following in your shell:

```bash
jdoherty marked this conversation as resolved.
Show resolved Hide resolved
cd infra/sam
sam build
sam deploy --guided --parameter-overrides BucketNameParam=my-unique-bucket-20230718
```

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

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

Expand Down
24 changes: 2 additions & 22 deletions examples/powertools-examples-cloudformation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

<properties>
<log4j.version>2.20.0</log4j.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<lambda.core.version>1.2.3</lambda.core.version>
<lambda.events.version>3.11.3</lambda.events.version>
<aws.sdk.version>2.21.0</aws.sdk.version>
Expand Down Expand Up @@ -169,24 +169,4 @@
</plugin>
</plugins>
</build>
<profiles>
jdoherty marked this conversation as resolved.
Show resolved Hide resolved
<!-- Use a profile to enforce AspectJ version 1.9.7 if we are Java 1.8 otherwise we'll get class
version mismatch issues. All subsequent Java releases build with the default AspectJ configuration
on the project.

Note:
- if you are running Java > 1.8, you can remove this profile altogether
- If you are running on Java 1.8, you should apply the aspectJ version here to the project, and remove
the profile.
-->
<profile>
<id>jdk8</id>
<activation>
<jdk>(,11)</jdk> <!-- 8 -->
</activation>
<properties>
<aspectj.version>1.9.7</aspectj.version>
</properties>
</profile>
</profiles>
</project>
24 changes: 2 additions & 22 deletions examples/powertools-examples-core-utilities/cdk/app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

<properties>
<log4j.version>2.20.0</log4j.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<aspectj.version>1.9.20</aspectj.version>
</properties>

Expand Down Expand Up @@ -138,24 +138,4 @@
</plugin>
</plugins>
</build>
<profiles>
<!-- Use a profile to enforce AspectJ version 1.9.7 if we are Java 1.8 otherwise we'll get class
version mismatch issues. All subsequent Java releases build with the default AspectJ configuration
on the project.

Note:
- if you are running Java > 1.8, you can remove this profile altogether
- If you are running on Java 1.8, you should apply the aspectJ version here to the project, and remove
the profile.
-->
<profile>
<id>jdk8</id>
<activation>
<jdk>(,11)</jdk> <!-- 8 -->
</activation>
<properties>
<aspectj.version>1.9.7</aspectj.version>
</properties>
</profile>
</profiles>
</project>
4 changes: 2 additions & 2 deletions examples/powertools-examples-core-utilities/cdk/infra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Powertools for AWS Lambda (Java) - Core Utilities Example with Gradle

This project demonstrates the Lambda for Powertools Java module deployed using [Serverless Application Model](https://aws.amazon.com/serverless/sam/) with
[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
[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
configuration guide [in the main project README](../../../README.md).

You can also use `sam init` to create a new Gradle-powered Powertools application - choose to use the **AWS Quick Start Templates**,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

plugins {
id 'java'
id "io.freefair.aspectj.post-compile-weaving" version "6.6.3"
id "io.freefair.aspectj.post-compile-weaving" version "8.2.2"
}

wrapper {
gradleVersion = "7.6.1"
gradleVersion = "8.5"
}

compileJava {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
sourceCompatibility = "11"
targetCompatibility = "11"

ajc {
enabled = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Resources:
Properties:
CodeUri: .
Handler: helloworld.App::handleRequest
Runtime: java8
Runtime: java11
MemorySize: 512
Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
Variables:
Expand All @@ -43,7 +43,7 @@ Resources:
Properties:
CodeUri: .
Handler: helloworld.AppStream::handleRequest
Runtime: java8
Runtime: java11
MemorySize: 512
Tracing: Active
Environment:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Powertools for AWS Lambda (Kotlin) - Core Utilities Example

This project demonstrates the Lambda for Powertools Kotlin module deployed using [Serverless Application Model](https://aws.amazon.com/serverless/sam/) with
[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
[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
configuration guide [in the main project README](../../../README.md).

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

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

tasks.compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}

tasks.compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}

// If using JDK 11 or higher, use the following instead:
//kotlin {
// jvmToolchain(11)
//}
kotlin {
jvmToolchain(11)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
24 changes: 2 additions & 22 deletions examples/powertools-examples-core-utilities/sam/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

<properties>
<log4j.version>2.20.0</log4j.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<aspectj.version>1.9.20</aspectj.version>
</properties>

Expand Down Expand Up @@ -126,24 +126,4 @@
</plugin>
</plugins>
</build>
<profiles>
<!-- Use a profile to enforce AspectJ version 1.9.7 if we are Java 1.8 otherwise we'll get class
version mismatch issues. All subsequent Java releases build with the default AspectJ configuration
on the project.

Note:
- if you are running Java > 1.8, you can remove this profile altogether
- If you are running on Java 1.8, you should apply the aspectJ version here to the project, and remove
the profile.
-->
<profile>
<id>jdk8</id>
<activation>
<jdk>(,11)</jdk> <!-- 8 -->
</activation>
<properties>
<aspectj.version>1.9.7</aspectj.version>
</properties>
</profile>
</profiles>
</project>
25 changes: 3 additions & 22 deletions examples/powertools-examples-core-utilities/serverless/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

<properties>
<log4j.version>2.20.0</log4j.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<aspectj.version>1.9.20</aspectj.version>
</properties>

Expand Down Expand Up @@ -59,6 +59,7 @@
</dependencies>

<build>
<finalName>helloworld-lambda</finalName>
<plugins>
<plugin>
<groupId>dev.aspectj</groupId>
Expand Down Expand Up @@ -126,24 +127,4 @@
</plugin>
</plugins>
</build>
<profiles>
<!-- Use a profile to enforce AspectJ version 1.9.7 if we are Java 1.8 otherwise we'll get class
version mismatch issues. All subsequent Java releases build with the default AspectJ configuration
on the project.

Note:
- if you are running Java > 1.8, you can remove this profile altogether
- If you are running on Java 1.8, you should apply the aspectJ version here to the project, and remove
the profile.
-->
<profile>
<id>jdk8</id>
<activation>
<jdk>(,11)</jdk> <!-- 8 -->
</activation>
<properties>
<aspectj.version>1.9.7</aspectj.version>
</properties>
</profile>
</profiles>
</project>
Loading