4
votes

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?

1
I don't immediately see any issues in your build.sbt file. Do you have any project/*.scala files which may be manipulating the expected values?joescii
What's your project/plugins.sbt? I suspect that publishSigned comes from sbt-pgp or sbt-sonatype.Jacek Laskowski
@joescii I have no *.scala files in the project directory.skozlov
@JacekLaskowski My project/plugins.sbt contains only logLevel := Level.Warn, but there is ~/.sbt/0.13/plugins/gpg.sbt with such content: addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8")skozlov

1 Answers

2
votes

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
)