4
votes

I recently published a package to bintray and added it to jcenter now, which enables me to publish my snapshots to oss.jfrog.org. I am using the bintray-sbt plugin for publishing.

To publish snapshots i added the following directive to my build.sbt:

publishTo := {
  if (isSnapshot.value)
    Some("OJO" at "https://oss.jfrog.org/oss-snapshot-local/")
  else
    publishTo.value /* Value set by bintray-sbt plugin */
}

Problem is, that when i try publishing a snapshot i get the following error:

[error] (*:bintrayRelease) failed to release richard-w/[email protected]: {"message":"Resource not found for path 'Richard-W/maven/play-reactivemongo'"}

which basically means, that bintray-sbt hooked itself into the publish TaskKey. The publishing process is ready at the time this error is encountered, but this seems unclean and hacky. Disabling automatic release gets rid of the error but it yields a meaningless warning.

My question is now: Can i disable the bintray-sbt plugin from build.sbt somehow when publishing snapshots? If this doesn't work: How do i configure sbt to publish to bintray without using bintray-sbt. I never got the URL-Pattern right when i tried.

1
Do you've found a solution for this issue?akkie
Nope. Not at all.Richard

1 Answers

0
votes

Struggled with the same problem for some time. Didn't manage to configure sbt-bintray, but configured bintray urls correctly. Here is my code:

object implicits {

  val bintrayUser = sbt.settingKey[String]("Bintray user name")
  val bintrayRepository = sbt.settingKey[String]("Bintray repository name")
  val bintrayPackage = sbt.settingKey[String]("Bintray package name")

  implicit class RichProject(project: Project) {

    def publish: Project = project.settings(
      bintrayUser := "your default user",
      bintrayRepository := "your repository",
      bintrayPackage := name.value,
      credentials += {
        if (isSnapshot.value) {
          Credentials((Path.userHome: RichFile) / ".ivy2/nexus.credentials")
        } else {
          Credentials((Path.userHome: RichFile) / ".ivy2/bintray.credentials")
        }
      },
      publishTo := {
        if (isSnapshot.value) {
          Some(("snapshots": RepositoryName) at "snapshots repo url")
        } else {
          Some(("releases": RepositoryName) at s"https://api.bintray.com/maven/${bintrayUser.value}/${bintrayRepository.value}/${bintrayPackage.value}/;publish=1")
        }
      }
    )    
  }

Also, notice I added some keys for bintray repository configuration. You can set these keys in child projects and override defaults.

I use these properties like this:

def library1: Project = publish.settings(
  organization := "io.library1",
  bintrayPackage := s"library1-${name.value}"
)

And then, in build.sbt I can do:

import implicits._
lazy val `library1-part1` = project.library1