Skip to content

Commit

Permalink
Adopt Java HttpClient in PackageSearchApiClient
Browse files Browse the repository at this point in the history
Switched to using Java HttpClient in PackageSearchApiClient. The kotlin/ktor client CIO and Java imports were added in PackageSearchApplicationCachesService and the corresponding ktor-client-java dependency was added to the build.gradle.kts file.

(cherry picked from commit 3d66a75)
  • Loading branch information
Lamberto Basti committed Jan 25, 2024
1 parent 86a5e8a commit ad03e21
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions packagesearch.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serializa
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerialization" }
kotlinx-serialization-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version.ref = "kotlinxSerialization" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
ktor-client-java = { module = "io.ktor:ktor-client-java", version.ref = "ktor" }
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
ktor-client-encoding = { module = "io.ktor:ktor-client-encoding", version.ref = "ktor" }
ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
Expand Down
1 change: 1 addition & 0 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ dependencies {
exclude(group = "org.jetbrains.compose.foundation")
}
implementation(packageSearchCatalog.ktor.client.logging)
implementation(packageSearchCatalog.ktor.client.java)
implementation(packageSearchCatalog.packagesearch.api.models)
implementation(projects.plugin.gradle.base)
implementation(projects.plugin.gradle.kmp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import com.jetbrains.packagesearch.plugin.utils.ApiSearchEntry
import com.jetbrains.packagesearch.plugin.utils.KtorDebugLogger
import com.jetbrains.packagesearch.plugin.utils.PackageSearchApiPackageCache
import com.jetbrains.packagesearch.plugin.utils.PackageSearchProjectService
import io.ktor.client.engine.cio.CIO
import io.ktor.client.engine.java.Java
import io.ktor.client.plugins.logging.LogLevel
import io.ktor.client.plugins.logging.Logging
import java.util.concurrent.CompletableFuture
Expand Down Expand Up @@ -77,7 +79,7 @@ class PackageSearchApplicationCachesService(private val coroutineScope: Coroutin

private val apiClient = PackageSearchApiClient(
endpoints = PackageSearchEndpoints.DEFAULT,
httpClient = PackageSearchApiClient.defaultHttpClient {
httpClient = PackageSearchApiClient.defaultHttpClient(Java) {
install(Logging) {
level = LogLevel.ALL
logger = KtorDebugLogger()
Expand Down

0 comments on commit ad03e21

Please sign in to comment.