From 1fafbf45c381ef413135e614ecfbd3df6e8d735e Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Fri, 5 May 2023 16:42:41 +1000 Subject: [PATCH] chore: Upgrade Kotlin to 1.8.21, KTor to 2.3, plugin driver to 0.4.0 --- .github/workflows/gradle.yml | 2 +- buildSrc/build.gradle | 4 +- ...dius.pact.kotlin-common-conventions.gradle | 42 ++++++++++--------- consumer/build.gradle | 1 + .../com/dius/pact/consumer/KTorMockServer.kt | 21 +++++----- .../au/com/dius/pact/consumer/PactTest.groovy | 3 +- core/model/build.gradle | 1 + core/support/build.gradle | 3 +- .../au/com/dius/pact/core/support/Metrics.kt | 3 +- .../pact/core/support/HttpClientSpec.groovy | 4 +- 10 files changed, 44 insertions(+), 40 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index d1e83fd179..c933392e60 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -40,7 +40,7 @@ jobs: strategy: matrix: module: [ core, consumer, provider, pact-specification-test ] - jdk: [ 11, 17, 18 ] + jdk: [ 17, 18 ] steps: - uses: actions/checkout@v2 - name: Set up JDK diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index f178d8f204..6eea951e3b 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -10,8 +10,8 @@ repositories { } dependencies { - implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22' + implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21' implementation 'io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.21.0' - implementation 'org.jetbrains.dokka:dokka-gradle-plugin:1.7.20' + implementation 'org.jetbrains.dokka:dokka-gradle-plugin:1.8.10' implementation 'org.apache.commons:commons-text:1.5' } diff --git a/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle b/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle index a1e6a4306b..41b7b79ce3 100644 --- a/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle +++ b/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle @@ -15,39 +15,41 @@ repositories { version = '4.6.0' java { - targetCompatibility = '11' - sourceCompatibility = '11' + targetCompatibility = '17' + sourceCompatibility = '17' } tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { kotlinOptions { - jvmTarget = "11" + jvmTarget = "17" } } dependencies { constraints { // Define dependency versions as constraints - api 'org.apache.httpcomponents.client5:httpclient5:5.1.3' - api 'org.apache.httpcomponents.client5:httpclient5-fluent:5.1.3' - api 'org.json:json:20220924' - api 'io.pact.plugin.driver:core:0.3.2' - api 'org.apache.tika:tika-core:1.28.5' + api 'org.apache.httpcomponents.client5:httpclient5:5.2.1' + api 'org.apache.httpcomponents.client5:httpclient5-fluent:5.2.1' + api 'org.json:json:20230227' + api 'io.pact.plugin.driver:core:0.4.0' + api 'org.apache.tika:tika-core:2.7.0' - implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' + implementation 'org.jetbrains.kotlin:kotlin-stdlib' implementation 'org.apache.commons:commons-lang3:3.12.0' implementation 'org.apache.commons:commons-text:1.10.0' implementation 'org.apache.commons:commons-collections4:4.4' - implementation 'org.apache.tika:tika-core:1.28.5' - implementation 'com.google.guava:guava:30.1.1-jre' - implementation 'org.slf4j:slf4j-api:1.7.32' - implementation 'io.ktor:ktor-http-jvm:1.6.8' - implementation 'io.ktor:ktor-server-netty:1.6.8' - implementation 'io.ktor:ktor-network-tls-certificates:1.6.8' - implementation 'io.netty:netty-handler:4.1.84.Final' + implementation 'org.apache.tika:tika-core:2.7.0' + implementation 'com.google.guava:guava:31.1-jre' + implementation 'org.slf4j:slf4j-api:1.7.36' + implementation 'io.ktor:ktor-http-jvm:2.3.0' + implementation 'io.ktor:ktor-server-netty:2.3.0' + implementation 'io.ktor:ktor-network-tls-certificates:2.3.0' + implementation 'io.ktor:ktor-server-call-logging:2.3.0' + implementation 'io.netty:netty-handler:4.1.86.Final' implementation 'org.apache.groovy:groovy:4.0.11' implementation 'org.apache.groovy:groovy-json:4.0.11' - implementation 'io.pact.plugin.driver:core:0.3.2' + implementation 'io.pact.plugin.driver:core:0.4.0' + implementation 'commons-codec:commons-codec:1.15' testImplementation 'org.apache.groovy:groovy:4.0.11' testImplementation 'org.apache.groovy:groovy-json:4.0.11' @@ -56,9 +58,9 @@ dependencies { testImplementation 'org.apache.groovy:groovy-nio:4.0.11' testImplementation 'org.hamcrest:hamcrest:2.2' testImplementation 'junit:junit:4.13.2' - testImplementation 'ch.qos.logback:logback-classic:1.4.4' - testImplementation 'ch.qos.logback:logback-core:1.4.4' - testImplementation 'net.bytebuddy:byte-buddy:1.12.7' + testImplementation 'ch.qos.logback:logback-classic:1.4.5' + testImplementation 'ch.qos.logback:logback-core:1.4.5' + testImplementation 'net.bytebuddy:byte-buddy:1.12.21' testImplementation 'com.github.tomakehurst:wiremock-jre8:2.34.0' testImplementation 'org.junit.vintage:junit-vintage-engine:5.9.2' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2' diff --git a/consumer/build.gradle b/consumer/build.gradle index 5386083da2..449a66275e 100644 --- a/consumer/build.gradle +++ b/consumer/build.gradle @@ -21,6 +21,7 @@ dependencies { implementation 'org.slf4j:slf4j-api' implementation 'io.ktor:ktor-server-netty' implementation 'io.ktor:ktor-network-tls-certificates' + implementation 'io.ktor:ktor-server-call-logging' implementation('io.pact.plugin.driver:core') { exclude group: 'au.com.dius.pact.core' } diff --git a/consumer/src/main/kotlin/au/com/dius/pact/consumer/KTorMockServer.kt b/consumer/src/main/kotlin/au/com/dius/pact/consumer/KTorMockServer.kt index f7118c8524..9fb1f1d69c 100644 --- a/consumer/src/main/kotlin/au/com/dius/pact/consumer/KTorMockServer.kt +++ b/consumer/src/main/kotlin/au/com/dius/pact/consumer/KTorMockServer.kt @@ -10,25 +10,24 @@ import au.com.dius.pact.core.model.Pact import au.com.dius.pact.core.model.Request import au.com.dius.pact.core.model.Response import au.com.dius.pact.core.support.Result -import io.ktor.application.ApplicationCall -import io.ktor.application.ApplicationCallPipeline -import io.ktor.application.install -import io.ktor.features.CallLogging import io.ktor.http.HttpMethod import io.ktor.http.HttpStatusCode -import io.ktor.request.httpMethod -import io.ktor.request.path -import io.ktor.request.receiveStream -import io.ktor.response.header -import io.ktor.response.respond -import io.ktor.response.respondBytes -import io.ktor.server.engine.ApplicationEngineEnvironment +import io.ktor.server.application.ApplicationCall +import io.ktor.server.application.ApplicationCallPipeline +import io.ktor.server.application.install import io.ktor.server.engine.applicationEngineEnvironment import io.ktor.server.engine.connector import io.ktor.server.engine.embeddedServer import io.ktor.server.engine.sslConnector import io.ktor.server.netty.Netty import io.ktor.server.netty.NettyApplicationEngine +import io.ktor.server.plugins.callloging.CallLogging +import io.ktor.server.request.httpMethod +import io.ktor.server.request.path +import io.ktor.server.request.receiveStream +import io.ktor.server.response.header +import io.ktor.server.response.respond +import io.ktor.server.response.respondBytes import io.ktor.util.network.hostname import io.ktor.util.network.port import io.netty.channel.Channel diff --git a/consumer/src/test/groovy/au/com/dius/pact/consumer/PactTest.groovy b/consumer/src/test/groovy/au/com/dius/pact/consumer/PactTest.groovy index 274adb920f..1a874003d4 100644 --- a/consumer/src/test/groovy/au/com/dius/pact/consumer/PactTest.groovy +++ b/consumer/src/test/groovy/au/com/dius/pact/consumer/PactTest.groovy @@ -5,6 +5,7 @@ import au.com.dius.pact.consumer.model.MockProviderConfig import au.com.dius.pact.core.model.PactSpecVersion import au.com.dius.pact.core.model.RequestResponsePact import groovy.json.JsonSlurper +import io.ktor.network.tls.certificates.KeyType import org.apache.hc.client5.http.classic.methods.HttpPost import org.apache.hc.client5.http.impl.classic.HttpClientBuilder import org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager @@ -77,7 +78,7 @@ class PactTest { .toPact() def jksFile = File.createTempFile('PactTest', '.jks') - def keystore = generateCertificate(jksFile, 'SHA1withRSA', 'PactTest', 'changeit', 'changeit', 1024) + def keystore = generateCertificate(jksFile, 'SHA1withRSA', 'PactTest', 'changeit', 'changeit', 1024, KeyType.Server) MockProviderConfig config = new MockHttpsProviderConfig('localhost', 8443, PactSpecVersion.V3, keystore, 'PactTest', 'changeit', 'changeit') diff --git a/core/model/build.gradle b/core/model/build.gradle index 8c8777c1a5..1b0b4cde3b 100644 --- a/core/model/build.gradle +++ b/core/model/build.gradle @@ -12,6 +12,7 @@ dependencies { implementation 'org.apache.commons:commons-lang3' implementation 'org.apache.commons:commons-collections4' + implementation 'commons-codec:commons-codec' implementation 'org.slf4j:slf4j-api' implementation 'com.github.mifmif:generex:1.0.2' implementation 'javax.mail:mail:1.5.0-b01' diff --git a/core/support/build.gradle b/core/support/build.gradle index 879d18b16f..3662037374 100644 --- a/core/support/build.gradle +++ b/core/support/build.gradle @@ -6,11 +6,12 @@ description = 'Pact-JVM Support module with common utilities' group = 'au.com.dius.pact.core' dependencies { - api 'io.github.microutils:kotlin-logging-jvm:2.1.23' + api 'io.github.microutils:kotlin-logging-jvm:3.0.4' api 'org.apache.httpcomponents.client5:httpclient5' api 'org.apache.httpcomponents.client5:httpclient5-fluent' implementation 'org.apache.commons:commons-text' + implementation 'commons-codec:commons-codec' testImplementation 'org.apache.groovy:groovy' testImplementation 'org.hamcrest:hamcrest' diff --git a/core/support/src/main/kotlin/au/com/dius/pact/core/support/Metrics.kt b/core/support/src/main/kotlin/au/com/dius/pact/core/support/Metrics.kt index aa673cdadb..1a84e8add5 100644 --- a/core/support/src/main/kotlin/au/com/dius/pact/core/support/Metrics.kt +++ b/core/support/src/main/kotlin/au/com/dius/pact/core/support/Metrics.kt @@ -3,11 +3,10 @@ package au.com.dius.pact.core.support import au.com.dius.pact.core.support.Utils.lookupVersion import mu.KLogging import org.apache.commons.codec.digest.DigestUtils -import java.util.concurrent.TimeUnit import org.apache.hc.client5.http.fluent.Request -import org.apache.hc.core5.http.ContentType import org.apache.hc.core5.http.message.BasicNameValuePair import java.util.UUID +import java.util.concurrent.TimeUnit /** * Metric events to send diff --git a/core/support/src/test/groovy/au/com/dius/pact/core/support/HttpClientSpec.groovy b/core/support/src/test/groovy/au/com/dius/pact/core/support/HttpClientSpec.groovy index 59d63848af..e5845e2fc7 100644 --- a/core/support/src/test/groovy/au/com/dius/pact/core/support/HttpClientSpec.groovy +++ b/core/support/src/test/groovy/au/com/dius/pact/core/support/HttpClientSpec.groovy @@ -1,6 +1,6 @@ package au.com.dius.pact.core.support -import org.apache.hc.client5.http.impl.classic.ProtocolExec +import org.apache.hc.client5.http.impl.classic.MainClientExec import org.apache.hc.client5.http.protocol.RequestDefaultHeaders import spock.lang.Specification @@ -16,7 +16,7 @@ class HttpClientSpec extends Specification { def defaultHeaders = null def execChain = result.component1().execChain while (defaultHeaders == null && execChain != null) { - if (execChain.handler instanceof ProtocolExec) { + if (execChain.handler instanceof MainClientExec) { def interceptor = execChain.handler.httpProcessor.requestInterceptors.find { it instanceof RequestDefaultHeaders }