Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #530: Disable logback-core in Java 8 and show warning messages #533

Merged
merged 3 commits into from
Oct 11, 2024
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
4 changes: 1 addition & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 15 additions & 3 deletions src/main/scala/xerial/sbt/sonatype/SonatypeClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
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 @@ -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"))
Expand Down
Loading