I try to publish my project to Maven Central using the sbt-sonatype Plugin.
Following the instructions here: https://github.com/xerial/sbt-sonatype#buildsbt
I have this configuration:
lazy val publicationSettings: Project => Project = _.settings(
publishMavenStyle := true,
publishTo := sonatypePublishToBundle.value,
sonatypeCredentialHost := "s01.oss.sonatype.org",
sonatypeRepository := "https://s01.oss.sonatype.org/service/local",
...
The credentials ~/.sbt/1.0/sonatype.sbt
:
credentials += Credentials("Sonatype Nexus Repository Manager",
"s01.oss.sonatype.org",
"myUser",
"myPassword")
plugins.sbt
:
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7")
But somehow it still looks for the credentials for oss.sonatype.org
:
sbt> sonatypeBundleRelease
[MISSING_CREDENTIAL] No credential is found for oss.sonatype.org. Prepare ~/.sbt/(sbt_version)/sonatype.sbt file.
at xerial.sbt.sonatype.SonatypeClient.$anonfun$directCredentials$1(SonatypeClient.scala:45)
at scala.Option.getOrElse(Option.scala:189)
If I change the host to oss.sonatype.org
in the credentials I get the following:
2021-04-18 17:53:04.183+0200 info [SonatypeService] sonatypeRepository : https://oss.sonatype.org/service/local - (SonatypeService.scala:23)
2021-04-18 17:53:04.185+0200 info [SonatypeService] sonatypeProfileName : pme123 - (SonatypeService.scala:24)
2021-04-18 17:53:04.186+0200 info [SonatypeClient] Reading staging repository profiles... - (SonatypeClient.scala:108)
[info] Preparing a new staging repository for [sbt-sonatype] camunda-dmn-tester-root 0.11.0-SNAPSHOT
2021-04-18 17:53:04.544+0200 info [SonatypeClient] Reading staging profiles... - (SonatypeClient.scala:120)
2021-04-18 17:53:04.685+0200 error [Sonatype]
wvlet.airframe.http.HttpClientException: [403: Forbidden] Request failed: <html>
<head>
Do I miss something?
It seems that the settings are only taken if running the command in the
project
.This works or at least fixes this problem.