Skip to content

Commit

Permalink
Show sbt-sonatype version in the log (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
xerial authored Jan 27, 2023
1 parent 507a241 commit 4475ab4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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
9 changes: 5 additions & 4 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.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("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

Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/xerial/sbt/sonatype/SonatypeClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand All @@ -61,7 +61,7 @@ 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
Expand All @@ -84,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 =
Expand Down
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
Expand All @@ -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}")

Expand Down
5 changes: 5 additions & 0 deletions src/test/scala/xerial/sbt/sonatype/SonatypeClientTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
// }
}

0 comments on commit 4475ab4

Please sign in to comment.