【问题标题】:How to publish to Sonatype using publishSigned from sbt-pgp?如何使用来自 sbt-pgp 的 publishSigned 发布到 Sonatype?
【发布时间】:2014-09-10 07:13:45
【问题描述】:

我想使用 sbt-pgp 0.8 发布一个带有 sbt 的 Scala 库。我在 Sonatype 注册了 groupId org.bitbucket.sergey_kozlov

我的build.sbt

organization := "org.bitbucket.sergey_kozlov"

name := "playingcards"

version := "0.1-SNAPSHOT"

publishMavenStyle := true

publishTo := {
    val nexus = "https://oss.sonatype.org/"
    if (isSnapshot.value)
        Some("snapshots" at nexus + "content/repositories/snapshots")
    else
        Some("releases"  at nexus + "service/local/staging/deploy/maven2")
}

publishArtifact in Test := false

pomIncludeRepository := { _ => false }

pomExtra :=
        <url>https://bitbucket.org/sergey_kozlov/playingcards</url>
        <licenses>
            <license>
                <name>The MIT License</name>
                <url>http://www.opensource.org/licenses/mit-license.php</url>
                <distribution>repo</distribution>
            </license>
        </licenses>
        <scm>
            <url>https://bitbucket.org/sergey_kozlov/playingcards.git</url>
            <connection>scm:git:ssh://git@bitbucket.org/sergey_kozlov/playingcards.git</connection>
        </scm>
        <developers>
            <developer>
                <id>skozlov</id>
                <name>Sergey Kozlov</name>
                <email>mail.sergey.kozlov@gmail.com</email>
                <roles>
                    <role>architect</role>
                    <role>developer</role>
                </roles>
            </developer>
        </developers>

libraryDependencies += "junit" % "junit" % "4.11"

libraryDependencies += "org.scalatest" % "scalatest_2.10" % "2.0" % "test"

还有~/.sbt/0.13/plugins/gpg.sbt

addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8")

project/ 目录下没有其他有助于构建定义的文件。

当我在 sbt 控制台输入publishSigned 时,我得到以下错误:

[error] (*:publishSigned) java.io.IOException: Access to URL https://oss.sonatype.org/content/repositories/snapshots/playingcards/playingcards_2.10/0.1-SNAPSHOT/playingcards_2.10-0.1-SNAPSHOT-sources.jar was refused by the server: Forbidden

请注意,该 URL 不包含 organization

如何正确发布我的工件?

【问题讨论】:

  • 我没有立即在您的 build.sbt 文件中看到任何问题。您是否有任何 project/*.scala 文件可能正在操纵预期值?
  • 你的project/plugins.sbt 是什么?我怀疑publishSigned 来自sbt-pgpsbt-sonatype
  • @joescii 我在project 目录中没有*.scala 文件。
  • @JacekLaskowski 我的project/plugins.sbt 只包含logLevel := Level.Warn,但有~/.sbt/0.13/plugins/gpg.sbt 有这样的内容:addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8")

标签: sbt nexus sonatype


【解决方案1】:

正如您指出的,您的网址缺少 organization 属性,这就是您收到此错误的原因。尝试在 sbt 控制台中运行 show organization 以确保您的组织属性正确。如果它没有帮助尝试在 sbt 中明确指定您的项目并在那里设置 organization 属性。

lazy val core = (project in file(".")).settings(
  organization := "org.bitbucket.sergey_kozlov"
  //other properties here
)

【讨论】:

  • 谢谢你的回答,我试试这个。
猜你喜欢
  • 2018-02-11
  • 1970-01-01
  • 2018-06-26
  • 2012-04-15
  • 2015-04-10
  • 2013-11-06
  • 2018-02-08
  • 2014-06-29
  • 2013-05-22
相关资源
最近更新 更多