From 4cab62f66b01d54d7fd275ae3968410323ce6d11 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Sat, 15 Feb 2025 21:03:16 +0100 Subject: [PATCH] Compile with JDK 21 & optimize --- build.gradle | 25 ++++++++++++------- gradle.properties | 4 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 3 +-- .../com/devsoap/tincheck/routes/Routes.java | 2 +- .../routes/requests/TinGenerateRequest.java | 4 +-- .../routes/requests/TinValidateRequest.java | 6 ++--- .../routes/responses/GenerationResult.java | 5 ++-- .../tincheck/services/TinCheckService.java | 2 +- 9 files changed, 28 insertions(+), 25 deletions(-) diff --git a/build.gradle b/build.gradle index ca620d6..24887c6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,15 @@ plugins { id "java" id "io.micronaut.application" version "$micronautApplicationVersion" + id "io.micronaut.aot" version "$micronautApplicationVersion" } version = findProperty('BUILD_VERSION') ?: 'latest' group = "com.devsoap" java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } repositories { @@ -19,17 +20,16 @@ dependencies { annotationProcessor 'org.projectlombok:lombok' testAnnotationProcessor 'org.projectlombok:lombok' + compileOnly 'org.projectlombok:lombok' - annotationProcessor(platform("io.micronaut:micronaut-bom:$micronautVersion")) - testAnnotationProcessor(platform("io.micronaut:micronaut-bom:$micronautVersion")) - - implementation(platform("io.micronaut:micronaut-bom:$micronautVersion")) - implementation 'org.projectlombok:lombok' + implementation(platform("io.micronaut.platform:micronaut-platform")) implementation 'com.fasterxml.jackson.core:jackson-databind' - implementation 'javax.validation:validation-api' implementation 'io.micronaut.views:micronaut-views-handlebars' + implementation 'jakarta.validation:jakarta.validation-api:3.1.1' + implementation 'jakarta.annotation:jakarta.annotation-api:3.0.0' + implementation "io.github.resilience4j:resilience4j-micronaut:$resilience4jVersion" implementation "io.github.resilience4j:resilience4j-ratelimiter:$resilience4jVersion" implementation "io.github.resilience4j:resilience4j-consumer:$resilience4jVersion" @@ -55,10 +55,17 @@ application { micronaut { version "$micronautVersion" runtime("netty") + aot { + cacheEnvironment = true + optimizeServiceLoading = true + optimizeClassLoading = true + convertYamlToJava = true + precomputeOperations = true + } } wrapper { - gradleVersion = '8.0' + gradleVersion = '8.12.1' } test { diff --git a/gradle.properties b/gradle.properties index d1e64cf..54505e9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ -micronautApplicationVersion=3.7.0 -micronautVersion=3.8.3 +micronautApplicationVersion=4.4.5 +micronautVersion=4.7.6 julToSlf4jVersion=1.7.29 guavaVersion=31.0.1-jre resilience4jVersion=2.0.2 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e650f02..e18bc25 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index f5feea6..f3b75f3 100755 --- a/gradlew +++ b/gradlew @@ -86,8 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/src/main/java/com/devsoap/tincheck/routes/Routes.java b/src/main/java/com/devsoap/tincheck/routes/Routes.java index 93c9aa7..9cfbef1 100644 --- a/src/main/java/com/devsoap/tincheck/routes/Routes.java +++ b/src/main/java/com/devsoap/tincheck/routes/Routes.java @@ -33,10 +33,10 @@ import io.micronaut.http.annotation.*; import io.micronaut.http.annotation.Error; import io.micronaut.http.server.util.HttpHostResolver; import io.micronaut.views.View; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import javax.validation.Valid; import java.time.LocalDate; import java.util.Map; diff --git a/src/main/java/com/devsoap/tincheck/routes/requests/TinGenerateRequest.java b/src/main/java/com/devsoap/tincheck/routes/requests/TinGenerateRequest.java index b684c83..f0a8f98 100644 --- a/src/main/java/com/devsoap/tincheck/routes/requests/TinGenerateRequest.java +++ b/src/main/java/com/devsoap/tincheck/routes/requests/TinGenerateRequest.java @@ -23,9 +23,9 @@ import com.devsoap.tincheck.tin.TinGenerator; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import io.micronaut.core.annotation.Introspected; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.time.LocalDate; @Introspected diff --git a/src/main/java/com/devsoap/tincheck/routes/requests/TinValidateRequest.java b/src/main/java/com/devsoap/tincheck/routes/requests/TinValidateRequest.java index 9e0fc9f..fd26129 100644 --- a/src/main/java/com/devsoap/tincheck/routes/requests/TinValidateRequest.java +++ b/src/main/java/com/devsoap/tincheck/routes/requests/TinValidateRequest.java @@ -21,11 +21,9 @@ package com.devsoap.tincheck.routes.requests; import com.fasterxml.jackson.annotation.JsonProperty; import io.micronaut.core.annotation.Introspected; -import lombok.Getter; -import lombok.RequiredArgsConstructor; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; @Introspected public record TinValidateRequest( diff --git a/src/main/java/com/devsoap/tincheck/routes/responses/GenerationResult.java b/src/main/java/com/devsoap/tincheck/routes/responses/GenerationResult.java index 6b421dc..91fda83 100644 --- a/src/main/java/com/devsoap/tincheck/routes/responses/GenerationResult.java +++ b/src/main/java/com/devsoap/tincheck/routes/responses/GenerationResult.java @@ -23,15 +23,14 @@ import com.devsoap.tincheck.tin.TinGenerator; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import io.micronaut.core.annotation.Introspected; -import jdk.jfr.Timestamp; +import jakarta.validation.constraints.NotNull; -import javax.validation.constraints.NotNull; import java.time.LocalDate; @Introspected public record GenerationResult( @JsonProperty("value") String value, - @JsonProperty("dateOfBirth") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") @Timestamp LocalDate dateOfBirth, + @JsonProperty("dateOfBirth") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") LocalDate dateOfBirth, @JsonProperty("gender") @NotNull TinGenerator.Gender gender, @JsonProperty("availableTokens") Long tokens ){ } \ No newline at end of file diff --git a/src/main/java/com/devsoap/tincheck/services/TinCheckService.java b/src/main/java/com/devsoap/tincheck/services/TinCheckService.java index abbcaf2..96408f7 100644 --- a/src/main/java/com/devsoap/tincheck/services/TinCheckService.java +++ b/src/main/java/com/devsoap/tincheck/services/TinCheckService.java @@ -24,11 +24,11 @@ import com.devsoap.tincheck.tin.TinGenerator; import com.devsoap.tincheck.routes.responses.GenerationResult; import com.devsoap.tincheck.routes.responses.ValidationResult; import io.github.resilience4j.micronaut.annotation.RateLimiter; +import jakarta.annotation.PostConstruct; import jakarta.inject.Singleton; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import javax.annotation.PostConstruct; import java.time.LocalDate; import java.util.LinkedHashMap; import java.util.List;