mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
Build: Add hacky workaround for retrying PublishToMavenRepository tasks
It's supposed to help with `Caused by: org.apache.http.NoHttpResponseException: api.bintray.com:443 failed to respond`
This commit is contained in:
@@ -152,6 +152,7 @@ rootProject.apply {
|
||||
from(rootProject.file("gradle/jps.gradle.kts"))
|
||||
from(rootProject.file("gradle/checkArtifacts.gradle.kts"))
|
||||
from(rootProject.file("gradle/checkCacheability.gradle.kts"))
|
||||
from(rootProject.file("gradle/retryPublishing.gradle.kts"))
|
||||
}
|
||||
|
||||
IdeVersionConfigurator.setCurrentIde(project)
|
||||
@@ -1074,4 +1075,4 @@ if (disableVerificationTasks) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ kotlin.compiler.newInferenceEnabled=true
|
||||
#bootstrap.kotlin.version=1.1.50-dev-1451
|
||||
bootstrap.kotlin.default.version=1.4.20-dev-1530
|
||||
|
||||
kotlin.build.publishing.attempts=20
|
||||
#signingRequired=true
|
||||
|
||||
## The following properties can be added to your local.properties file to customize the build:
|
||||
|
||||
34
gradle/retryPublishing.gradle.kts
Normal file
34
gradle/retryPublishing.gradle.kts
Normal file
@@ -0,0 +1,34 @@
|
||||
allprojects {
|
||||
configurePublishingRetry()
|
||||
}
|
||||
|
||||
fun Project.configurePublishingRetry() {
|
||||
val publishingAttempts = findProperty("kotlin.build.publishing.attempts")?.toString()?.toInt()
|
||||
|
||||
fun retry(attempts: Int, action: () -> Unit): Boolean {
|
||||
repeat(attempts) {
|
||||
try {
|
||||
action()
|
||||
return true
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun <T: Task> T.configureRetry(attempts: Int, taskAction: T.() -> Unit) {
|
||||
doFirst {
|
||||
if (retry(attempts) { taskAction() })
|
||||
throw StopExecutionException()
|
||||
else
|
||||
error("Number of attempts ($attempts) exceeded for ${project.path}:$name")
|
||||
}
|
||||
}
|
||||
|
||||
if (publishingAttempts != null && publishingAttempts > 1) {
|
||||
tasks.withType<PublishToMavenRepository> {
|
||||
configureRetry(publishingAttempts, PublishToMavenRepository::publish)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user