Procházet zdrojové kódy

updated dependencies

sirekanian před 3 roky
rodič
revize
84b4816a58

+ 5 - 5
build.gradle.kts

@@ -12,11 +12,11 @@ repositories {
 }
 
 dependencies {
-    implementation("com.android.tools.build:gradle:4.0.0")
-    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1")
-    implementation("io.ktor:ktor-client-cio:1.4.3")
-    implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.11.3")
-    implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.11.3")
+    implementation("com.android.tools.build:gradle:4.0.2")
+    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
+    implementation("io.ktor:ktor-client-cio:2.1.3")
+    implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4")
+    implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.4")
 }
 
 gradlePlugin {

+ 12 - 14
src/main/kotlin/com/sirekanyan/bump/VersionChecker.kt

@@ -9,8 +9,9 @@ import com.sirekanyan.bump.model.Metadata
 import com.sirekanyan.bump.model.Version
 import com.sirekanyan.bump.model.createArtifactKey
 import io.ktor.client.*
-import io.ktor.client.features.*
+import io.ktor.client.plugins.*
 import io.ktor.client.request.*
+import io.ktor.client.statement.*
 import io.ktor.http.*
 import kotlinx.coroutines.*
 import org.gradle.api.artifacts.Dependency
@@ -46,23 +47,20 @@ class VersionChecker(
 
     private fun CoroutineScope.downloadMetadataAsync(key: ArtifactKey): Deferred<String?> =
         async(Dispatchers.IO) {
-            try {
-                if (key.url.startsWith("file:/")) {
-                    val path = key.url.replace(Regex("^file:/+"), "/")
-                    val file = File(path)
-                    if (file.exists()) {
-                        file.readText()
-                    } else {
-                        null
-                    }
+            if (key.url.startsWith("file:/")) {
+                val path = key.url.replace(Regex("^file:/+"), "/")
+                val file = File(path)
+                if (file.exists()) {
+                    file.readText()
                 } else {
-                    httpClient.get<String>(key.url)
+                    null
                 }
-            } catch (exception: ClientRequestException) {
-                if (exception.response.status.value == 404) {
+            } else {
+                val response = httpClient.get(key.url)
+                if (response.status == HttpStatusCode.NotFound) {
                     null
                 } else {
-                    throw exception
+                    response.bodyAsText()
                 }
             }
         }