Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: xerial/sbt-sonatype
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.9.16
Choose a base ref
...
head repository: xerial/sbt-sonatype
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.9.17
Choose a head ref
  • 5 commits
  • 6 files changed
  • 4 contributors

Commits on Jan 26, 2023

  1. Increase max retries to 1000 and disable the circuit breaker (#364)

    * Increase max retries to 1000
    
    100 is not enough for some slow Sonatype repository.
    
    This PR should fix #363
    
    * Disables the circuit breaker, because Sonatype can be down for a long time #363
    Atry authored Jan 26, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    joyeecheung Joyee Cheung
    Copy the full SHA
    b79a6af View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    joyeecheung Joyee Cheung
    Copy the full SHA
    bd20d26 View commit details

Commits on Jan 27, 2023

  1. Copy the full SHA
    a903389 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    aduh95 Antoine du Hamel
    Copy the full SHA
    507a241 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    aduh95 Antoine du Hamel
    Copy the full SHA
    4475ab4 View commit details
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -42,10 +42,12 @@ lazy val sbtSonatype =
project
.withId("sbt-sonatype")
.in(file("."))
.enablePlugins(ScriptedPlugin)
.enablePlugins(ScriptedPlugin, BuildInfoPlugin)
.settings(
buildSettings,
testFrameworks += new TestFramework("wvlet.airspec.Framework"),
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoPackage := "org.xerial.sbt.sonatype",
libraryDependencies ++= Seq(
"org.sonatype.spice.zapper" % "spice-zapper" % "1.3",
"org.wvlet.airframe" %% "airframe-http" % AIRFRAME_VERSION
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.7.3
sbt.version=1.8.2
11 changes: 6 additions & 5 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
val SONATYPE_VERSION = sys.env.getOrElse("SONATYPE_VERSION", "3.9.15")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % SONATYPE_VERSION)
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")
val SONATYPE_VERSION = sys.env.getOrElse("SONATYPE_VERSION", "3.9.16")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % SONATYPE_VERSION)
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")

libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value

10 changes: 6 additions & 4 deletions src/main/scala/xerial/sbt/sonatype/SonatypeClient.scala
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ class SonatypeClient(
credt
}

private val base64Credentials = {
private lazy val base64Credentials = {
val credt = directCredentials
Base64.getEncoder.encodeToString(s"${credt.userName}:${credt.passwd}".getBytes(StandardCharsets.UTF_8))
}
@@ -61,8 +61,10 @@ class SonatypeClient(
new java.net.URL(repoUri).getPath
}

private val clientConfig = {
private[sonatype] val clientConfig = {
Http.client
// Disables the circuit breaker, because Sonatype can be down for a long time https://github.com/xerial/sbt-sonatype/issues/363
.noCircuitBreaker
// Use URLConnectionClient for JDK8 compatibility. Remove this line when using JDK11 or later
.withBackend(URLConnectionClientBackend)
.withJSONEncoding
@@ -72,7 +74,7 @@ class SonatypeClient(
.withRetryContext { context =>
// For individual REST calls, use a normal jittering
context
.withMaxRetry(100)
.withMaxRetry(1000)
.withJitter(initialIntervalMillis = 1500, maxIntervalMillis = 30000)
}
.withRequestFilter { request =>
@@ -82,7 +84,7 @@ class SonatypeClient(
}
}

private val httpClient = clientConfig.newSyncClient(repoUri)
private[sonatype] val httpClient = clientConfig.newSyncClient(repoUri)

// Create stage is not idempotent, so we just need to wait for a long time without retry
private val httpClientForCreateStage =
6 changes: 4 additions & 2 deletions src/main/scala/xerial/sbt/sonatype/SonatypeService.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package xerial.sbt.sonatype

import java.io.File
import org.xerial.sbt.sonatype.BuildInfo

import java.io.File
import sbt.io.IO
import wvlet.airframe.codec.MessageCodecFactory
import wvlet.log.LogSupport
import xerial.sbt.sonatype.SonatypeClient._
import xerial.sbt.sonatype.SonatypeClient.*
import xerial.sbt.sonatype.SonatypeException.{MISSING_PROFILE, MISSING_STAGING_PROFILE, MULTIPLE_TARGETS, UNKNOWN_STAGE}

import scala.util.Try
@@ -23,6 +24,7 @@ class SonatypeService(

def this(sonatypClient: SonatypeClient, profileName: String) = this(sonatypClient, profileName, None)

info(s"sbt-sonatype version: ${BuildInfo.version}")
info(s"sonatypeRepository : ${sonatypClient.repoUri}")
info(s"sonatypeProfileName : ${profileName}")

5 changes: 5 additions & 0 deletions src/test/scala/xerial/sbt/sonatype/SonatypeClientTest.scala
Original file line number Diff line number Diff line change
@@ -23,4 +23,9 @@ class SonatypeClientTest extends AirSpec {

profile shouldBe unpacked
}

// test("create client") {
// val client = new SonatypeClient("https://httpbin.org/", Seq.empty, "")
// client.httpClient.readAs[Json](Http.GET("/status/500"))
// }
}