Skip to content

Commit

Permalink
Merge pull request #727 from armanbilge/fix/sonatype-credential-host-…
Browse files Browse the repository at this point in the history
…scoping

Set `sonatypeCredentialHost` at build-level
  • Loading branch information
armanbilge authored Jul 29, 2024
2 parents 626ef87 + ee70b5b commit 17ac909
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import com.typesafe.tools.mima.plugin.MimaPlugin
import sbt._
import xerial.sbt.Sonatype

import scala.annotation.nowarn

import Keys._
import Sonatype.autoImport._
import TypelevelKernelPlugin.autoImport._
Expand All @@ -31,6 +33,10 @@ object TypelevelSonatypePlugin extends AutoPlugin {
override def trigger = allRequirements

object autoImport {
@deprecated(
"Use ThisBuild / sonatypeCredentialHost := xerial.sbt.Sonatype.sonatypeLegacy",
"0.7.3"
)
lazy val tlSonatypeUseLegacyHost =
settingKey[Boolean]("Publish to oss.sonatype.org instead of s01 (default: false)")
}
Expand All @@ -48,25 +54,26 @@ object TypelevelSonatypePlugin extends AutoPlugin {
}
)

@nowarn("cat=deprecation")
override def buildSettings =
Seq(
tlSonatypeUseLegacyHost := false,
autoAPIMappings := true
autoAPIMappings := true,
sonatypeCredentialHost := {
Option(System.getenv("SONATYPE_CREDENTIAL_HOST")).filter(_.nonEmpty).getOrElse {
if (tlSonatypeUseLegacyHost.value)
Sonatype.sonatypeLegacy
else
Sonatype.sonatype01
}
}
)

override def projectSettings = Seq(
publishMavenStyle := true, // we want to do this unconditionally, even if publishing a plugin
sonatypeProfileName := organization.value,
publishTo := sonatypePublishToBundle.value,
commands += sonatypeBundleReleaseIfRelevant,
sonatypeCredentialHost := {
Option(System.getenv("SONATYPE_CREDENTIAL_HOST")).filter(_.nonEmpty).getOrElse {
if (tlSonatypeUseLegacyHost.value)
"oss.sonatype.org"
else
"s01.oss.sonatype.org"
}
},
apiURL := apiURL.value.orElse(hostedApiUrl.value)
)

Expand Down

0 comments on commit 17ac909

Please sign in to comment.