From 8f8b3702bdbb03b7135a85c297dd58db99bd188a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Fri, 26 Jul 2024 19:50:12 +0200 Subject: [PATCH] Fix computation of sonatypeDefaultResolver for Sonatype Central (#501) --- src/main/scala/xerial/sbt/Sonatype.scala | 2 +- src/sbt-test/sbt-sonatype/sonatype-central-host/build.sbt | 8 ++++++++ .../sonatype-central-host/project/plugins.sbt | 8 ++++++++ src/sbt-test/sbt-sonatype/sonatype-central-host/test | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/sbt-test/sbt-sonatype/sonatype-central-host/build.sbt create mode 100644 src/sbt-test/sbt-sonatype/sonatype-central-host/project/plugins.sbt create mode 100644 src/sbt-test/sbt-sonatype/sonatype-central-host/test diff --git a/src/main/scala/xerial/sbt/Sonatype.scala b/src/main/scala/xerial/sbt/Sonatype.scala index 0a47bc40..91b2d9c0 100755 --- a/src/main/scala/xerial/sbt/Sonatype.scala +++ b/src/main/scala/xerial/sbt/Sonatype.scala @@ -141,7 +141,7 @@ object Sonatype extends AutoPlugin with LogSupport { }, sonatypeDefaultResolver := { if (sonatypeCredentialHost.value == SonatypeCentralClient.host) { - Resolver.url(s"https://$sonatypeCredentialHost") + Resolver.url(s"https://${sonatypeCredentialHost.value}") } else { val profileM = sonatypeTargetRepositoryProfile.?.value val repository = sonatypeRepository.value diff --git a/src/sbt-test/sbt-sonatype/sonatype-central-host/build.sbt b/src/sbt-test/sbt-sonatype/sonatype-central-host/build.sbt new file mode 100644 index 00000000..693273dd --- /dev/null +++ b/src/sbt-test/sbt-sonatype/sonatype-central-host/build.sbt @@ -0,0 +1,8 @@ +sonatypeCredentialHost := xerial.sbt.sonatype.SonatypeCentralClient.host + +val checkSonatypeDefaultResolver = taskKey[Unit]("Check if the default resolver is Sonatype") +checkSonatypeDefaultResolver := { + val actual = sonatypeDefaultResolver.value + val expected = Resolver.url("https://central.sonatype.com") + require(actual == expected, s"expected $actual to be $expected") +} diff --git a/src/sbt-test/sbt-sonatype/sonatype-central-host/project/plugins.sbt b/src/sbt-test/sbt-sonatype/sonatype-central-host/project/plugins.sbt new file mode 100644 index 00000000..4776b262 --- /dev/null +++ b/src/sbt-test/sbt-sonatype/sonatype-central-host/project/plugins.sbt @@ -0,0 +1,8 @@ +{ + val pluginVersion = System.getProperty("plugin.version") + if (pluginVersion == null) + throw new RuntimeException("""|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin) + else + addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % pluginVersion) +} diff --git a/src/sbt-test/sbt-sonatype/sonatype-central-host/test b/src/sbt-test/sbt-sonatype/sonatype-central-host/test new file mode 100644 index 00000000..5c098f80 --- /dev/null +++ b/src/sbt-test/sbt-sonatype/sonatype-central-host/test @@ -0,0 +1 @@ +> checkSonatypeDefaultResolver