Skip to content

Commit

Permalink
#276: Always use ThisBuild / sonatypeCredentialHost settings (#285)
Browse files Browse the repository at this point in the history
* Use ThisBuild / sonatypeXXX settings within commands

* reformat

* cleanup

* Cleanup

* cleanup
  • Loading branch information
xerial authored Feb 17, 2022
1 parent 245cf62 commit 11975c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ lazy val buildSettings: Seq[Setting[_]] = Seq(
organizationName := "Xerial project",
organizationHomepage := Some(new URL("http://xerial.org/")),
description := "A sbt plugin for publishing Scala/Java projects to the Maven Central through Sonatype Nexus REST API",
publishArtifact in Test := false,
Test / publishArtifact := false,
sbtPlugin := true,
parallelExecution := true,
scalacOptions ++= Seq("-encoding", "UTF-8", "-deprecation", "-unchecked"),
Expand All @@ -33,7 +33,7 @@ lazy val buildSettings: Seq[Setting[_]] = Seq(
},
crossSbtVersions := Vector("1.2.8"),
releaseCrossBuild := false,
releaseTagName := { (version in ThisBuild).value },
releaseTagName := { (ThisBuild / version).value },
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
Expand Down
15 changes: 9 additions & 6 deletions src/main/scala/xerial/sbt/Sonatype.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ object Sonatype extends AutoPlugin with LogSupport {
)
lazy val sonatypeSettings = Seq[Def.Setting[_]](
sonatypeProfileName := organization.value,
sonatypeRepository := s"https://${sonatypeCredentialHost.value}/service/local",
sonatypeRepository := s"https://${(ThisBuild / sonatypeCredentialHost).value}/service/local",
sonatypeProjectHosting := None,
publishMavenStyle := true,
pomIncludeRepository := { _ =>
Expand Down Expand Up @@ -413,10 +413,13 @@ object Sonatype extends AutoPlugin with LogSupport {
val logLevel = LogLevel(extracted.get(sonatypeLogLevel))
wvlet.log.Logger.setDefaultLogLevel(logLevel)

val repositoryUrl = extracted.get(sonatypeRepository)
val creds = getCredentials(extracted, state)
val credentialHost = extracted.get(sonatypeCredentialHost)
// #276 Need to use the root configuration
val credentialHost = extracted.get(ThisBuild / sonatypeCredentialHost)
val currentSonatypeProfile = profileName.getOrElse(extracted.get(sonatypeProfileName))
val repositoryUrl = extracted.get(sonatypeRepository)
val timeoutMillis = extracted.get(sonatypeTimeoutMillis)

val creds = getCredentials(extracted, state)
val hashsum: String = {
val input = Vector(repositoryUrl, creds.toString(), credentialHost).mkString("-")
MurmurHash3.stringHash(input).abs.toString()
Expand All @@ -426,11 +429,11 @@ object Sonatype extends AutoPlugin with LogSupport {
repositoryUrl = repositoryUrl,
cred = creds,
credentialHost = credentialHost,
timeoutMillis = extracted.get(sonatypeTimeoutMillis)
timeoutMillis = timeoutMillis
)
val service = new SonatypeService(
sonatypeClient,
profileName.getOrElse(extracted.get(sonatypeProfileName)),
currentSonatypeProfile,
Some(hashsum)
)
try {
Expand Down

0 comments on commit 11975c3

Please sign in to comment.