skozlov
skozlov

Reputation: 414

How to publish to Sonatype using publishSigned from sbt-pgp?

I want to publish a Scala library with sbt using sbt-pgp 0.8. I've registered groupId org.bitbucket.sergey_kozlov at Sonatype.

My 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://[email protected]/sergey_kozlov/playingcards.git</connection>
        </scm>
        <developers>
            <developer>
                <id>skozlov</id>
                <name>Sergey Kozlov</name>
                <email>[email protected]</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"

There's also ~/.sbt/0.13/plugins/gpg.sbt:

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

No other files are under project/ directory that contribute to the build definition.

When I enter publishSigned in sbt console, I get the following error:

[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

Note that the URL does not contain organization.

How can I publish my artifact correctly?

Upvotes: 4

Views: 881

Answers (1)

Avershin Dmitry
Avershin Dmitry

Reputation: 275

As you pointed out your URL is missing organization property this is why you get this error. Try to run show organization in sbt console to be sure that your organization property is correct. If it doesn't help try to specify your project explicitly in sbt and set organization property there.

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

Upvotes: 2

Related Questions