Skip to content

Commit

Permalink
Initial Java 21 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew2184 committed Dec 23, 2023
1 parent 5d04795 commit e379683
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 122 deletions.
27 changes: 11 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

version: '3.9'
version: "3.9"
services:
spring-native-aws-lambda-function:
image: ghcr.io/muhamadto/spring-native-amazonlinux2-builder:20-amazonlinux2-awscliv2
Expand All @@ -31,6 +31,7 @@ services:
AWS_REGION: ap-southeast-2
AWS_ACCESS_KEY_ID: local
AWS_SECRET_ACCESS_KEY: local
AWS_ENDPOINT_URL: http://localstack:4566
MAVEN_OPTS: |
-DskipTests=true
-Dcheckstyle.skip=true
Expand All @@ -52,10 +53,10 @@ services:
print_info_message "block" "Creating 'spring-native-aws-lambda-function'" &&
print_info_message "divider" "Package GraalVM function" &&
./mvnw -ntp clean package -U -Pnative -pl spring-native-aws-lambda-function --settings ./settings-spring.xml &&
lambda_create_function lambda-FUNCTION provided.al2 512 ./spring-native-aws-lambda-function/target/spring-native-aws-lambda-function-native-zip.zip spring-native-aws-lambda-function &&
lambda_create_function lambda-FUNCTION provided.al2023 512 ./spring-native-aws-lambda-function/target/spring-native-aws-lambda-function-native-zip.zip spring-native-aws-lambda-function &&
lambda_wait_for_function lambda-FUNCTION &&
lambda_list_functions &&
Expand All @@ -67,20 +68,14 @@ services:
- localstack

localstack:
container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
image: localstack/localstack:latest
container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}"
image: localstack/localstack
ports:
- "127.0.0.1:4566:4566" # LocalStack Gateway
- "127.0.0.1:4510-4559:4510-4559" # external services port range
- "127.0.0.1:4566:4566" # LocalStack Gateway
- "127.0.0.1:4510-4559:4510-4559" # external services port range
environment:
- DEBUG=${DEBUG-}
- DOCKER_HOST=unix:///var/run/docker.sock
- LOCALSTACK_HOST=localstack
# LocalStack configuration: https://docs.localstack.cloud/references/configuration/
- DEBUG=${DEBUG:-0}
volumes:
- "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"





55 changes: 24 additions & 31 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.1</version>
<relativePath />
</parent>

<groupId>com.coffeebeans</groupId>
<artifactId>spring-native-aws-lambda</artifactId>
<name>${project.artifactId}</name>
Expand All @@ -44,13 +51,9 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
<maven.compiler.release>20</maven.compiler.release>
<java.version>21</java.version>
<maven.compiler.parameters>true</maven.compiler.parameters>

<jackson.version>2.13.0</jackson.version>

<sonar.organization>muhamadto</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

Expand All @@ -73,15 +76,8 @@

<sonar.coverage.exclusions>**/model/*.java, **/Application.java, **/*Hints.java
</sonar.coverage.exclusions>
<lombok.version>1.18.28</lombok.version>
</properties>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.2</version>
</parent>

<modules>
<module>spring-native-aws-lambda-function</module>
<module>spring-native-aws-lambda-infra</module>
Expand All @@ -107,35 +103,35 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.11.1</version>
<version>3.11.4</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-serialization</artifactId>
<version>1.1.2</version>
<version>1.1.5</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-log4j2</artifactId>
<version>1.5.1</version>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-logging</artifactId>
<version>1.16.1</version>
<version>1.18.0</version>
</dependency>
<!-- AWS END -->

<!-- UTILS -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
<version>3.14.0</version>
</dependency>

<dependency>
Expand All @@ -153,7 +149,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.0.0-jre</version>
<version>33.0.0-jre</version>
</dependency>

<dependency>
Expand All @@ -168,33 +164,30 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-parameter-names</artifactId>
<version>${jackson.version}</version>
<version>${jackson-bom.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- JACKSON ENDS -->

<!-- AWS CDK -->
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>aws-cdk-lib</artifactId>
<version>2.90.0</version>
<version>2.115.0</version>
</dependency>
<!-- AWS CDK ENDS -->

Expand All @@ -209,21 +202,21 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.23.1</version>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.1</version>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.8.1</version>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<!-- TEST ENDS -->
Expand All @@ -237,17 +230,17 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>3.12.0</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.10</version>
<version>0.8.11</version>
<executions>
<execution>
<id>pre-unit-test</id>
Expand Down Expand Up @@ -301,4 +294,4 @@
</comments>
</license>
</licenses>
</project>
</project>
31 changes: 12 additions & 19 deletions spring-native-aws-lambda-function/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,8 @@
</developers>

<properties>
<spring-cloud.version>2022.0.3</spring-cloud.version>

<repackage.classifier/>
<native.build.args>
--enable-url-protocols=http
-H:+AddAllCharsets
-H:+ReportExceptionStackTraces
</native.build.args>
<spring-cloud.version>2023.0.0</spring-cloud.version>
<repackage.classifier />
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -169,19 +163,18 @@
<artifactId>native-maven-plugin</artifactId>
<configuration>
<mainClass>com.coffeebeans.springnativeawslambda.Application</mainClass>
<buildArgs>
--no-fallback
<buildArgs combine.children="append">
<buildArg>--verbose</buildArg>
<buildArg>--no-fallback</buildArg>
<buildArg>--enable-preview</buildArg>
<buildArg>--gc=G1</buildArg>
<buildArg>-march=native</buildArg>
<buildArg>--strict-image-heap</buildArg>
<buildArg>--enable-url-protocols=http</buildArg>
<buildArg>-H:+AddAllCharsets</buildArg>
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
</buildArgs>
</configuration>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
@SpringBootApplication
@ImportRuntimeHints({
ReflectionRuntimeHints.class,
ResourcesRuntimeHints.class,
SerializationRuntimeHints.class
ResourcesRuntimeHints.class
})
public class Application {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,30 @@
package com.coffeebeans.springnativeawslambda;

import java.util.List;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
import com.coffeebeans.springnativeawslambda.model.Request;
import com.coffeebeans.springnativeawslambda.model.Response;
import org.joda.time.DateTime;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.TypeReference;
import org.springframework.lang.Nullable;

public class ReflectionRuntimeHints implements RuntimeHintsRegistrar {

@Override
public void registerHints(final RuntimeHints hints, final ClassLoader classLoader) {
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
final List<TypeReference> typeReferences = List.of(
TypeReference.of(DateTime.class)
);
TypeReference.of(DateTime.class),
TypeReference.of(Response.class),
TypeReference.of(Request.class),
TypeReference.of(APIGatewayProxyResponseEvent.class),
TypeReference.of(APIGatewayProxyRequestEvent.class),
TypeReference.of(APIGatewayProxyRequestEvent.ProxyRequestContext.class),
TypeReference.of(APIGatewayProxyRequestEvent.RequestIdentity.class));

hints.reflection().registerTypes(typeReferences,
builder -> builder.withMembers(MemberCategory.values()));
hints.reflection().registerTypes(typeReferences, builder -> builder.withMembers(MemberCategory.values()));
}
}
}

This file was deleted.

Loading

0 comments on commit e379683

Please sign in to comment.