diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index c1b4a2f..3b991fa 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -19,21 +19,21 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up JDK 17 - uses: actions/setup-java@v3 + - name: Set up JDK 21 + uses: actions/setup-java@v4 with: - java-version: '17' + java-version: '21' distribution: 'temurin' - name: Setup Gradle to generate and submit dependency graphs - uses: gradle/gradle-build-action@v2.9.0 + uses: gradle/actions/setup-gradle@v3 with: dependency-graph: generate-and-submit - name: Build with Gradle - run: ./gradlew build integrationTest bootBuildImage + run: ./gradlew build testCodeCoverageReport integrationTestCodeCoverageReport integrationTest bootBuildImage env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Run sonar analysis with Gradle - run: ./gradlew testCodeCoverageReport integrationTestCodeCoverageReport sonar + run: ./gradlew sonar env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/application/build.gradle.kts b/application/build.gradle.kts index 416914f..1845079 100644 --- a/application/build.gradle.kts +++ b/application/build.gradle.kts @@ -13,12 +13,12 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-security") implementation("org.springframework.boot:spring-boot-starter-logging") implementation("org.springframework.kafka:spring-kafka") - implementation("com.gxf.utilities:kafka-azure-oauth:0.2") - implementation("org.apache.httpcomponents:httpclient:4.5.14") { + implementation(libs.kafkaAzureOAuth) + implementation(libs.apacheHttpClient) { exclude("commons-logging") } implementation(kotlin("reflect")) - implementation("io.github.microutils:kotlin-logging-jvm:3.0.5") + implementation(libs.logging) implementation("org.springframework:spring-aspects") @@ -30,6 +30,8 @@ dependencies { testImplementation("org.mockito:mockito-junit-jupiter") testImplementation("org.assertj:assertj-core") + testRuntimeOnly("org.junit.platform:junit-platform-launcher") + // Generate test and integration test reports jacocoAggregation(project(":application")) } @@ -57,7 +59,7 @@ testing { implementation("org.springframework.kafka:spring-kafka-test") implementation("org.assertj:assertj-core") implementation("org.springframework.boot:spring-boot-starter-webflux") - implementation("org.wiremock:wiremock-standalone:3.3.1") + implementation(testLibs.mockServer) } } } diff --git a/application/src/main/kotlin/org/gxf/soapbridge/configuration/properties/SecurityConfigurationProperties.kt b/application/src/main/kotlin/org/gxf/soapbridge/configuration/properties/SecurityConfigurationProperties.kt index 2213040..a9bb8d3 100644 --- a/application/src/main/kotlin/org/gxf/soapbridge/configuration/properties/SecurityConfigurationProperties.kt +++ b/application/src/main/kotlin/org/gxf/soapbridge/configuration/properties/SecurityConfigurationProperties.kt @@ -4,7 +4,7 @@ package org.gxf.soapbridge.configuration.properties -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.boot.context.properties.ConfigurationProperties import java.io.IOException import java.nio.file.Files @@ -55,7 +55,7 @@ class SigningConfigurationProperties( val privateKeyFactory = KeyFactory.getInstance(keyType, provider) privateKeyFactory.generatePrivate(privateKeySpec) } catch (e: Exception) { - logger.error("Unexpected exception during private key creation", e) + logger.error(e) { "Unexpected exception during private key creation" } null } } @@ -69,7 +69,7 @@ class SigningConfigurationProperties( val publicKeyFactory = KeyFactory.getInstance(keyType, provider) publicKeyFactory.generatePublic(publicKeySpec) } catch (e: Exception) { - logger.error("Unexpected exception during public key creation", e) + logger.error(e) { "Unexpected exception during public key creation" } null } } diff --git a/application/src/main/kotlin/org/gxf/soapbridge/kafka/listeners/ProxyRequestKafkaListener.kt b/application/src/main/kotlin/org/gxf/soapbridge/kafka/listeners/ProxyRequestKafkaListener.kt index 04777ce..39f0162 100644 --- a/application/src/main/kotlin/org/gxf/soapbridge/kafka/listeners/ProxyRequestKafkaListener.kt +++ b/application/src/main/kotlin/org/gxf/soapbridge/kafka/listeners/ProxyRequestKafkaListener.kt @@ -4,7 +4,7 @@ package org.gxf.soapbridge.kafka.listeners -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.apache.kafka.clients.consumer.ConsumerRecord import org.gxf.soapbridge.application.services.PlatformCommunicationService import org.gxf.soapbridge.valueobjects.ProxyServerRequestMessage diff --git a/application/src/main/kotlin/org/gxf/soapbridge/kafka/listeners/ProxyResponseKafkaListener.kt b/application/src/main/kotlin/org/gxf/soapbridge/kafka/listeners/ProxyResponseKafkaListener.kt index b087b02..12aef09 100644 --- a/application/src/main/kotlin/org/gxf/soapbridge/kafka/listeners/ProxyResponseKafkaListener.kt +++ b/application/src/main/kotlin/org/gxf/soapbridge/kafka/listeners/ProxyResponseKafkaListener.kt @@ -4,7 +4,7 @@ package org.gxf.soapbridge.kafka.listeners -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.apache.kafka.clients.consumer.ConsumerRecord import org.gxf.soapbridge.application.services.ClientCommunicationService import org.gxf.soapbridge.valueobjects.ProxyServerResponseMessage diff --git a/application/src/main/kotlin/org/gxf/soapbridge/kafka/senders/ProxyRequestKafkaSender.kt b/application/src/main/kotlin/org/gxf/soapbridge/kafka/senders/ProxyRequestKafkaSender.kt index 96fc475..e2a3c99 100644 --- a/application/src/main/kotlin/org/gxf/soapbridge/kafka/senders/ProxyRequestKafkaSender.kt +++ b/application/src/main/kotlin/org/gxf/soapbridge/kafka/senders/ProxyRequestKafkaSender.kt @@ -4,7 +4,7 @@ package org.gxf.soapbridge.kafka.senders -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.gxf.soapbridge.kafka.properties.TopicsConfigurationProperties import org.gxf.soapbridge.valueobjects.ProxyServerRequestMessage import org.springframework.kafka.core.KafkaTemplate diff --git a/application/src/main/kotlin/org/gxf/soapbridge/kafka/senders/ProxyResponseKafkaSender.kt b/application/src/main/kotlin/org/gxf/soapbridge/kafka/senders/ProxyResponseKafkaSender.kt index 0841fd2..15492c4 100644 --- a/application/src/main/kotlin/org/gxf/soapbridge/kafka/senders/ProxyResponseKafkaSender.kt +++ b/application/src/main/kotlin/org/gxf/soapbridge/kafka/senders/ProxyResponseKafkaSender.kt @@ -4,7 +4,7 @@ package org.gxf.soapbridge.kafka.senders -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.gxf.soapbridge.kafka.properties.TopicsConfigurationProperties import org.gxf.soapbridge.valueobjects.ProxyServerResponseMessage import org.springframework.kafka.core.KafkaTemplate diff --git a/application/src/main/kotlin/org/gxf/soapbridge/valueobjects/ProxyServerRequestMessage.kt b/application/src/main/kotlin/org/gxf/soapbridge/valueobjects/ProxyServerRequestMessage.kt index a7c07b0..5c8761d 100644 --- a/application/src/main/kotlin/org/gxf/soapbridge/valueobjects/ProxyServerRequestMessage.kt +++ b/application/src/main/kotlin/org/gxf/soapbridge/valueobjects/ProxyServerRequestMessage.kt @@ -4,7 +4,7 @@ package org.gxf.soapbridge.valueobjects -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.gxf.soapbridge.exceptions.ProxyMessageException import java.util.* @@ -43,7 +43,7 @@ class ProxyServerRequestMessage( "Invalid number of tokens, not trying to create ProxyServerRequestMessage." ) } - if (LOGGER.isDebugEnabled) { + if (LOGGER.isDebugEnabled()) { printValues(numTokens, split) } val connectionId = split[0] @@ -67,16 +67,16 @@ class ProxyServerRequestMessage( } private fun printValues(numTokens: Int, split: List) { - if (LOGGER.isDebugEnabled) { - LOGGER.debug("split[0] connection-id: {}", split[0]) - LOGGER.debug("split[2] context : {}", decode(split[1])) - LOGGER.debug("split[3] encoded soap-request length: {}", split[2]!!.length) - LOGGER.debug("split[3] soap-request : {}", decode(split[2])) + if (LOGGER.isDebugEnabled()) { + LOGGER.debug { "split[0] connection-id: ${split[0]}" } + LOGGER.debug { "split[2] context : ${decode(split[1])}" } + LOGGER.debug { "split[3] encoded soap-request length: ${split[2]!!.length}" } + LOGGER.debug { "split[3] soap-request : ${decode(split[2])}" } if (numTokens == 5) { - LOGGER.debug("split[4] security-key : {}", split[3]) + LOGGER.debug { "split[4] security-key : ${split[3]}" } } else { - LOGGER.debug("split[4] common-name : {}", decode(split[3])) - LOGGER.debug("split[5] security-signature : {}", split[4]) + LOGGER.debug { "split[4] common-name : ${decode(split[3])}" } + LOGGER.debug { "split[5] security-signature : ${split[4]}" } } } } diff --git a/application/src/main/kotlin/org/gxf/soapbridge/valueobjects/ProxyServerResponseMessage.kt b/application/src/main/kotlin/org/gxf/soapbridge/valueobjects/ProxyServerResponseMessage.kt index a6ad773..58a0bd9 100644 --- a/application/src/main/kotlin/org/gxf/soapbridge/valueobjects/ProxyServerResponseMessage.kt +++ b/application/src/main/kotlin/org/gxf/soapbridge/valueobjects/ProxyServerResponseMessage.kt @@ -4,7 +4,7 @@ package org.gxf.soapbridge.valueobjects -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.gxf.soapbridge.exceptions.ProxyMessageException import java.util.* @@ -38,11 +38,11 @@ class ProxyServerResponseMessage(connectionId: String, val soapResponse: String) "Invalid number of tokens, don't try to create ProxyServerResponseMessage" ) } - if (logger.isDebugEnabled) { - logger.debug("split[0] connection-id: {}", split[0]) - logger.debug("split[1] encoded soap-response length: {}", split[1].length) - logger.debug("split[1] soap-response: {}", decode(split[1])) - logger.debug("split[2] security-key : {}", split[2]) + if (logger.isDebugEnabled()) { + logger.debug { "split[0] connection-id: ${split[0]}" } + logger.debug { "split[1] encoded soap-response length: ${split[1].length}" } + logger.debug { "split[1] soap-response: ${decode(split[1])}" } + logger.debug { "split[2] security-key : ${split[2]}" } } val proxyServerResponseMessage = ProxyServerResponseMessage(split[0], decode(split[1])) proxyServerResponseMessage.signature = split[2] diff --git a/build.gradle.kts b/build.gradle.kts index ed36620..5cd8d76 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,16 +1,18 @@ // Copyright 2023 Alliander N.V. +import com.github.davidmc24.gradle.plugin.avro.GenerateAvroJavaTask import io.spring.gradle.dependencymanagement.internal.dsl.StandardDependencyManagementExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - id("org.springframework.boot") version "3.2.1" apply false - id("io.spring.dependency-management") version "1.1.4" apply false - kotlin("jvm") version "1.9.22" apply false - kotlin("plugin.spring") version "1.9.22" apply false - kotlin("plugin.jpa") version "1.9.22" apply false + id("org.springframework.boot") version "3.3.1" apply false + id("io.spring.dependency-management") version "1.1.5" apply false + kotlin("jvm") version "2.0.0" apply false + kotlin("plugin.spring") version "2.0.0" apply false + kotlin("plugin.jpa") version "2.0.0" apply false id("com.github.davidmc24.gradle.plugin.avro") version "1.9.1" apply false - id("org.sonarqube") version "4.4.1.3373" + id("org.sonarqube") version "5.0.0.4638" id("eclipse") } @@ -48,25 +50,25 @@ subprojects { } } - extensions.configure { - toolchain { - languageVersion.set(JavaLanguageVersion.of(21)) - } - } - extensions.configure { imports { mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES) } } - tasks.withType { - kotlinOptions { + extensions.configure { + jvmToolchain { + languageVersion = JavaLanguageVersion.of(21) + } + compilerOptions { freeCompilerArgs = listOf("-Xjsr305=strict") - jvmTarget = "21" } } + tasks.withType { + dependsOn(tasks.withType()) + } + tasks.withType { useJUnitPlatform() } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a595206..0d18421 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index 7b2730b..cd30151 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,3 +3,24 @@ rootProject.name = "gxf-soap-bridge" include("application") + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + version("kotlinLogging", "7.0.0") + version("gxfUtils", "0.3.7") + version("apacheHttpClient", "4.5.14") + + + library("logging", "io.github.oshai", "kotlin-logging-jvm").versionRef("kotlinLogging") + + library("kafkaAzureOAuth", "com.gxf.utilities", "kafka-azure-oauth").versionRef("gxfUtils") + library("apacheHttpClient", "org.apache.httpcomponents", "httpclient").versionRef("apacheHttpClient") + } + create("testLibs") { + version("wiremock", "3.6.0") + + library("mockServer", "org.wiremock", "wiremock-standalone").versionRef("wiremock") + } + } +}