From 4bc046c4444549e548a8d24f9ace1dfcb9523440 Mon Sep 17 00:00:00 2001 From: Artem IG Date: Fri, 21 Oct 2022 19:14:38 +0300 Subject: [PATCH 1/3] fmt --- src/main/kotlin/Types.kt | 4 ++-- src/main/kotlin/stages/upload/Http.kt | 24 +++++++++++------------- src/main/kotlin/tools/Thrower.kt | 5 +++++ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/Types.kt b/src/main/kotlin/Types.kt index 2c139c3..0cedc39 100644 --- a/src/main/kotlin/Types.kt +++ b/src/main/kotlin/Types.kt @@ -10,7 +10,6 @@ import java.nio.file.Path import kotlin.io.path.* - @JvmInline value class JarFile(val path: Path) @@ -44,6 +43,7 @@ fun MavenUrl.toPomUrl(notation: Notation): URL { open class ExpectedException(msg: String) : Exception(msg) class FailedToParseValueException(value: String) : ExpectedException("Failed to parse '${value}'") -class ValueException(name: String, value: Any, cause: Throwable? = null): IllegalArgumentException("$name: <$value>", cause) +class ValueException(name: String, value: Any, cause: Throwable? = null): + IllegalArgumentException("$name: <$value>", cause) diff --git a/src/main/kotlin/stages/upload/Http.kt b/src/main/kotlin/stages/upload/Http.kt index 41acb64..d27debd 100644 --- a/src/main/kotlin/stages/upload/Http.kt +++ b/src/main/kotlin/stages/upload/Http.kt @@ -35,17 +35,11 @@ private fun insecureHttpLogging() = System.getenv("INSECURE_HTTP_LOGGING") == "1 fun createClient(user: SonatypeUsername, pass: SonatypePassword): HttpClient = HttpClient { -// install(HttpRequestRetry) { -// retryOnServerErrors(maxRetries = 10) -// exponentialDelay() -// retryOnException(maxRetries = 10) // HttpTimeout выбрасывает исключения -// } -// -// install(HttpTimeout) { -// this.requestTimeoutMillis = 10*60*1000 -// this.connectTimeoutMillis = 5*1000 -// this.socketTimeoutMillis = this.connectTimeoutMillis -// } + install(HttpRequestRetry) { + retryOnServerErrors(maxRetries = 4) + exponentialDelay() + retryOnException(maxRetries = 4) // HttpTimeout выбрасывает исключения + } install(Logging) { logger = object : Logger { @@ -191,10 +185,14 @@ private val json = Json { encodeDefaults = true } suspend fun HttpClient.promoteToCentral(uri: StagingUri) { - // иногда тут бывает + // 2022-10 загадочная ошибка: // Error: Exception in thread "main" java.lang.IllegalStateException: Failed to promote: // 500 Server Error - // {"errors":[{"id":"*","msg":"Unhandled: Staging repository is already transitioning: iogithubrtmigo-1183"}]} + // {"errors":[ + // {"id":"*", + // "msg":"Unhandled: Staging repository is already transitioning: iogithubrtmigo-1183"}]} + // Можно бы предположить, что мы пытались сделать promote дважды. Но нет: логи показывают, + // мы при первом вызове иногда сразу "already transitioning" eprintHeader("Promoting Staging to Release") this.post("https://s01.oss.sonatype.org/service/local/staging/bulk/promote") { diff --git a/src/main/kotlin/tools/Thrower.kt b/src/main/kotlin/tools/Thrower.kt index 31e30e0..951bdca 100644 --- a/src/main/kotlin/tools/Thrower.kt +++ b/src/main/kotlin/tools/Thrower.kt @@ -1,3 +1,8 @@ +/** + * SPDX-FileCopyrightText: (c) 2022 Artsiom iG (rtmigo.github.io) + * SPDX-License-Identifier: ISC + **/ + package tools inline fun rethrowingState( From 645b5065edd9507f5dd9f663644fe2fd5d45c5fe Mon Sep 17 00:00:00 2001 From: Artem IG Date: Fri, 21 Oct 2022 19:47:35 +0300 Subject: [PATCH 2/3] checking gradlew is executable --- src/main/kotlin/stages/build/GradleTypes.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/stages/build/GradleTypes.kt b/src/main/kotlin/stages/build/GradleTypes.kt index a96d94a..91d238a 100644 --- a/src/main/kotlin/stages/build/GradleTypes.kt +++ b/src/main/kotlin/stages/build/GradleTypes.kt @@ -6,10 +6,6 @@ import java.nio.file.Path import kotlin.io.path.* -//class AbsPath(src: Path) { -// val path: Path = src.absolute() -//} - @JvmInline value class ProjectRootDir(val path: Path) { init { @@ -39,6 +35,10 @@ value class BuildGradleFile(val path: Path) { @JvmInline value class GradlewFile(val path: Path) { init { - require(path.name == "gradlew" || path.name == "gradlew.bat") + require(path.name == "gradlew" || path.name == "gradlew.bat") { + "Unexpected filename" + } + if (path.name == "gradlew") + check(path.isExecutable()) { "gradlew is not executable" } } } \ No newline at end of file From 112f7ed903fece6a9cc055c449e5b949b47a94a7 Mon Sep 17 00:00:00 2001 From: Artem IG Date: Fri, 21 Oct 2022 20:10:02 +0300 Subject: [PATCH 3/3] checking `jar` is executable !!release --- build.gradle.kts | 2 +- src/main/kotlin/tools/Jar.kt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d27c611..d5f9094 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "io.github.rtmigo" -version = "0.4.1-SNAPSHOT" // +version = "0.4.1" // -SNAPSHOTjar repositories { mavenCentral() diff --git a/src/main/kotlin/tools/Jar.kt b/src/main/kotlin/tools/Jar.kt index df03116..5465324 100644 --- a/src/main/kotlin/tools/Jar.kt +++ b/src/main/kotlin/tools/Jar.kt @@ -37,7 +37,9 @@ object Jar { } initialized = true if (jarExeCache == null) - throw IllegalStateException("JAR not found") + throw IllegalStateException("`jar` executable not found") + if (!Path(jarExeCache!!).isExecutable()) + throw IllegalStateException("'$jarExeCache' is not executable") return jarExeCache!! } }