Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ package io.spine.dependency.local
/**
* Dependencies on the Spine Compiler modules.
*
* To use a locally published ProtoData version instead of the version from a public plugin
* To use a locally published Compiler version instead of the version from a public plugin
* registry, set the `COMPILER_VERSION` and/or the `COMPILER_DF_VERSION` environment variables
* and stop the Gradle daemons so that Gradle observes the env change:
* ```
Expand Down Expand Up @@ -67,22 +67,22 @@ object Compiler {
const val module = "io.spine.tools:compiler"

/**
* The version of ProtoData dependencies.
* The version of the Compiler dependencies.
*/
val version: String
private const val fallbackVersion = "2.0.0-SNAPSHOT.030"
private const val fallbackVersion = "2.0.0-SNAPSHOT.034"

/**
* The distinct version of ProtoData used by other build tools.
* The distinct version of the Compiler used by other build tools.
*
* When ProtoData is used both for building the project and as a part of the Project's
* transitional dependencies, this is the version used to build the project itself.
* When the Compiler is used both for building the project and as a part of the Project's
* transitive dependencies, this is the version used to build the project itself.
*/
val dogfoodingVersion: String
private const val fallbackDfVersion = "2.0.0-SNAPSHOT.030"

/**
* The artifact for the ProtoData Gradle plugin.
* The artifact for the Compiler Gradle plugin.
*/
val pluginLib: String

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ object CoreJvmCompiler {
/**
* The version used to in the build classpath.
*/
const val dogfoodingVersion = "2.0.0-SNAPSHOT.034"
const val dogfoodingVersion = "2.0.0-SNAPSHOT.035"

/**
* The version to be used for integration tests.
*/
const val version = "2.0.0-SNAPSHOT.034"
const val version = "2.0.0-SNAPSHOT.035"

/**
* The ID of the Gradle plugin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object Validation {
/**
* The version of the Validation library artifacts.
*/
const val version = "2.0.0-SNAPSHOT.354"
const val version = "2.0.0-SNAPSHOT.360"

/**
* The last version of Validation compatible with ProtoData.
Expand Down
48 changes: 46 additions & 2 deletions buildSrc/src/main/kotlin/io/spine/gradle/git/Repository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@

package io.spine.gradle.git

import com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly
import io.spine.gradle.Cli
import io.spine.gradle.fs.LazyTempPath
import java.util.concurrent.TimeUnit.MILLISECONDS
import org.gradle.api.logging.Logger

/**
Expand Down Expand Up @@ -133,8 +135,10 @@ class Repository private constructor(
* Performs a pull with rebase before pushing to ensure the local branch is up-to-date.
*/
fun push() {
repoExecute("git", "pull", "--rebase")
repoExecute("git", "push")
withRetries(description = "Pushing to $sshUrl, branch = '$currentBranch'") {
repoExecute("git", "pull", "--rebase")
repoExecute("git", "push")
}
}

override fun close() {
Expand Down Expand Up @@ -174,3 +178,43 @@ class Repository private constructor(
}
}
}

/**
* Executes a given operation with retries using exponential backoff strategy.
*
* If the operation fails, it will be retried up to the specified number of times
* with increasing delays between attempts.
* The delay increases exponentially but is capped at the specified maximum value.
*
* If all retries fail, the exception from the final attempt will be thrown to the caller.
*
* @param T the type of value returned by the operation
* @param times the maximum number of attempts to execute the operation (default: 3)
* @param initialDelay the delay before the first retry in milliseconds (default: 100ms)
* @param maxDelay the maximum delay between retries in milliseconds (default: 2000ms)
* @param factor the multiplier used to increase delay after each failure (default: 2.0)
* @param description a description of the operation for error reporting (default: empty string)
* @param block the operation to execute
* @return the result of the successful operation execution
*/
private fun <T> withRetries(
times: Int = 3,
initialDelay: Long = 100, // ms
maxDelay: Long = 2000, // ms
factor: Double = 2.0,
description: String = "",
block: () -> T
): T {
var currentDelay = initialDelay
repeat(times - 1) {
try {
return block()
} catch (e: Exception) {
System.err.println("'$description' failed. " +
"Message: '${e.message}'. Retrying in $currentDelay ms.")
}
sleepUninterruptibly(currentDelay, MILLISECONDS)
currentDelay = (currentDelay * factor).toLong().coerceAtMost(maxDelay)
}
return block()
}
Loading