如何使用sbt-pgp中的publishSigned发布到Sonatype?

时间:2014-07-19 05:17:25

标签: sbt nexus sonatype

我想使用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

请注意,该网址不包含organization

如何正确发布我的工件?

1 个答案:

答案 0 :(得分:2)

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

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