From 0a8a9a0887e86676238eaf4567a5ab2f2309c9cd Mon Sep 17 00:00:00 2001 From: antoniocalo Date: Wed, 27 Nov 2024 10:29:44 +0100 Subject: [PATCH 1/2] P4ADEV-1531 upgrade JDK alpine version --- Dockerfile | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6e801fc..b4e6d4f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,8 @@ # # 🎯 Version Management # -ARG CORRETTO_VERSION="21-alpine3.17" -ARG CORRETTO_SHA="6ed399441760d860717318db95fc50846bd0173145ec728733e69b782ead78e4" +ARG CORRETTO_VERSION="21-alpine3.20" +ARG CORRETTO_SHA="8b16834e7fabfc62d4c8faa22de5df97f99627f148058d52718054aaa4ea3674" ARG GRADLE_VERSION="8.10.2" ARG GRADLE_DOWNLOAD_SHA256="31c55713e40233a8303827ceb42ca48a47267a0ad4bab9177123121e71524c26" ARG APPINSIGHTS_VERSION="3.5.2" diff --git a/README.md b/README.md index d3f835e..b849051 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Here is a quick overview of the files and directories included in this repositor ### 🔧 Gradle - `build.gradle` file with dependencies and plugins for building, testing, and running your Java application. -- Compatible with Java 8+. +- Compatible with Java 21+. ### ☕ Java - Example Java application structure with a simple `HelloWorld` class. From b74ad068a074e5506c70bf35474eee5ced38950c Mon Sep 17 00:00:00 2001 From: antoniocalo Date: Wed, 27 Nov 2024 11:12:18 +0100 Subject: [PATCH 2/2] P4ADEV-1531 refactor --- README.md | 5 +-- build.gradle.kts | 6 ++-- .../pagopa/template/TemplateApplication.java} | 6 ++-- .../pagopa/template/config/SwaggerConfig.java | 35 +++++++++++++++++++ .../pagopa/template}/utils/Calculator.java | 2 +- .../template}/utils/CalculatorTest.java | 4 +-- 6 files changed, 48 insertions(+), 10 deletions(-) rename src/main/java/{PayhubApplication.java => it/gov/pagopa/template/TemplateApplication.java} (60%) create mode 100644 src/main/java/it/gov/pagopa/template/config/SwaggerConfig.java rename src/main/java/{ => it/gov/pagopa/template}/utils/Calculator.java (70%) rename src/test/java/{ => it/gov/pagopa/template}/utils/CalculatorTest.java (88%) diff --git a/README.md b/README.md index b849051..7bee0aa 100644 --- a/README.md +++ b/README.md @@ -11,15 +11,16 @@ Here is a quick overview of the files and directories included in this repositor ```plaintext . ├── .github/ # GitHub configuration files -├── openapi/ # OpenAPI specification files +├── gradle/ # Gradle wrapper files ├── helm/ # Helm charts for Kubernetes deployments +├── openapi/ # OpenAPI specification files ├── src/ # Source code for the Java application │ ├── main/ │ └── test/ ├── build.gradle.kts # Gradle build file -├── settings.gradle.kts # Gradle settings file ├── Dockerfile # Docker build file ├── README.md # Project documentation +├── settings.gradle.kts # Gradle settings file └── .gitignore # Git ignore rules ``` diff --git a/build.gradle.kts b/build.gradle.kts index 37a8c91..87cff1e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -108,15 +108,15 @@ configure { } springBoot { - mainClass.value("it.gov.pagopa.payhub.template.payments.java.repository.PayhubApplication") + mainClass.value("it.gov.pagopa.template.TemplateApplication") } openApiGenerate { generatorName.set("spring") inputSpec.set("$rootDir/openapi/template-payments-java-repository.openapi.yaml") outputDir.set("$projectDir/build/generated") - apiPackage.set("it.gov.pagopa.payhub.controller.generated") - modelPackage.set("it.gov.pagopa.payhub.model.generated") + apiPackage.set("it.gov.pagopa.template.controller.generated") + modelPackage.set("it.gov.pagopa.template.model.generated") configOptions.set(mapOf( "dateLibrary" to "java8", "requestMappingMode" to "api_interface", diff --git a/src/main/java/PayhubApplication.java b/src/main/java/it/gov/pagopa/template/TemplateApplication.java similarity index 60% rename from src/main/java/PayhubApplication.java rename to src/main/java/it/gov/pagopa/template/TemplateApplication.java index 069a8ee..42b42d3 100644 --- a/src/main/java/PayhubApplication.java +++ b/src/main/java/it/gov/pagopa/template/TemplateApplication.java @@ -1,11 +1,13 @@ +package it.gov.pagopa.template; + import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class PayhubApplication { +public class TemplateApplication { public static void main(String[] args) { - SpringApplication.run(PayhubApplication.class, args); + SpringApplication.run(TemplateApplication.class, args); } } diff --git a/src/main/java/it/gov/pagopa/template/config/SwaggerConfig.java b/src/main/java/it/gov/pagopa/template/config/SwaggerConfig.java new file mode 100644 index 0000000..4b6b49d --- /dev/null +++ b/src/main/java/it/gov/pagopa/template/config/SwaggerConfig.java @@ -0,0 +1,35 @@ +package it.gov.pagopa.template.config; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * The Class SwaggerConfig. + */ +@Configuration +public class SwaggerConfig { + + /** The title. */ + @Value("${swagger.title:${spring.application.name}}") + private String title; + + /** The description. */ + @Value("${swagger.description:Api and Models}") + private String description; + + /** The version. */ + @Value("${swagger.version:${spring.application.version}}") + private String version; + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI().components(new Components()).info(new Info() + .title(title) + .description(description) + .version(version)); + } +} diff --git a/src/main/java/utils/Calculator.java b/src/main/java/it/gov/pagopa/template/utils/Calculator.java similarity index 70% rename from src/main/java/utils/Calculator.java rename to src/main/java/it/gov/pagopa/template/utils/Calculator.java index 2e78382..5906f6c 100644 --- a/src/main/java/utils/Calculator.java +++ b/src/main/java/it/gov/pagopa/template/utils/Calculator.java @@ -1,4 +1,4 @@ -package utils; +package it.gov.pagopa.template.utils; public class Calculator { diff --git a/src/test/java/utils/CalculatorTest.java b/src/test/java/it/gov/pagopa/template/utils/CalculatorTest.java similarity index 88% rename from src/test/java/utils/CalculatorTest.java rename to src/test/java/it/gov/pagopa/template/utils/CalculatorTest.java index b6169e5..2bba8fb 100644 --- a/src/test/java/utils/CalculatorTest.java +++ b/src/test/java/it/gov/pagopa/template/utils/CalculatorTest.java @@ -1,6 +1,6 @@ -package utils; +package it.gov.pagopa.template.utils; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName;