diff --git a/build.sbt b/build.sbt index 6cc89545..2a4b7912 100755 --- a/build.sbt +++ b/build.sbt @@ -83,9 +83,7 @@ lazy val sbtSonatype = libraryDependencies ++= Seq( "org.sonatype.spice.zapper" % "spice-zapper" % versions.sonatypeZapperClient, "org.wvlet.airframe" %% "airframe-http" % versions.airframe - // Logback 1.5.8 dropposed Java 8 support - exclude ("ch.qos.logback", "logback-core") - // A workaround for sbt-pgp, which still depends on scala-parser-combinator 1.x + // A workaround for sbt-pgp, which still depends on scala-parser-combinator 1.x excludeAll (ExclusionRule("org.scala-lang.modules", "scala-parser-combinators_2.12")), "org.wvlet.airframe" %% "airspec" % versions.airframe % Test, "com.lumidion" %% "sonatype-central-client-sttp-core" % versions.sonatypeClient, diff --git a/sbt b/sbt index f63a9ee5..7554340a 100755 --- a/sbt +++ b/sbt @@ -34,11 +34,11 @@ set -o pipefail -declare -r sbt_release_version="1.9.7" -declare -r sbt_unreleased_version="1.9.7" +declare -r sbt_release_version="1.10.2" +declare -r sbt_unreleased_version="1.10.2" -declare -r latest_213="2.13.12" -declare -r latest_212="2.12.18" +declare -r latest_213="2.13.15" +declare -r latest_212="2.12.20" declare -r latest_211="2.11.12" declare -r latest_210="2.10.7" declare -r latest_29="2.9.3" diff --git a/src/main/scala/xerial/sbt/sonatype/SonatypeClient.scala b/src/main/scala/xerial/sbt/sonatype/SonatypeClient.scala index 80ccfa0b..fdd026e2 100644 --- a/src/main/scala/xerial/sbt/sonatype/SonatypeClient.scala +++ b/src/main/scala/xerial/sbt/sonatype/SonatypeClient.scala @@ -39,10 +39,8 @@ class SonatypeClient( @nowarn("msg=URLConnectionClientBackend") private[sonatype] val clientConfig = { - Http.client + var config = Http.client .withName("sonatype-client") - // Put the log file under target/sbt-sonatype directory - .withLoggerConfig(_.withLogFileName("target/sbt-sonatype/sonatype_client_logs.json")) // 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 @@ -62,6 +60,20 @@ class SonatypeClient( .withAccept(MediaType.ApplicationJson) .withHeader(HttpHeader.Authorization, s"Basic ${base64Credentials}") } + + val javaVersion = sys.props.getOrElse("java.version", "unknown") + if (javaVersion.startsWith("1.")) { + warn( + s"Disabled http client logging as Java version ${javaVersion} is no longer supported. Please use Java 17 or later." + ) + config = config.noLogging + } else { + // Put the log file under target/sbt-sonatype directory + config = config.withLoggerConfig { + _.withLogFileName("target/sbt-sonatype/sonatype_client_logs.json") + } + } + config } private[sonatype] val httpClient = clientConfig.newSyncClient(repoUri.toString) diff --git a/src/test/scala/xerial/sbt/sonatype/SonatypeClientTest.scala b/src/test/scala/xerial/sbt/sonatype/SonatypeClientTest.scala index 4a2d56a4..274a1b74 100644 --- a/src/test/scala/xerial/sbt/sonatype/SonatypeClientTest.scala +++ b/src/test/scala/xerial/sbt/sonatype/SonatypeClientTest.scala @@ -24,6 +24,11 @@ class SonatypeClientTest extends AirSpec { profile shouldBe unpacked } + test("build client") { + val client = new SonatypeClient("https://oss.sonatype.org/service/local/", Seq.empty, "") + client.httpClient + } + // test("create client") { // val client = new SonatypeClient("https://httpbin.org/", Seq.empty, "") // client.httpClient.readAs[Json](Http.GET("/status/500"))