How can I post snapshots when using sbt with bintray-sbt plugin?
I recently published a package for bintray and added it to jcenter now, which allows me to post my snapshots to oss.jfrog.org. I am using bintray-sbt plugin for publishing.
To post the snapshots, I added the following directive to my build.sbt file:
publishTo := { if (isSnapshot.value) Some("OJO" at "https://oss.jfrog.org/oss-snapshot-local/") else publishTo.value /* Value set by bintray-sbt plugin */ }
The problem is that when I try to publish a snapshot, I get the following error:
[error] (*:bintrayRelease) failed to release richard-w/play-reactivemongo@0.2-SNAPSHOT: {"message":"Resource not found for path 'Richard-W/maven/play-reactivemongo'"}
which basically means bintray-sbt is hooked on posting TaskKey. The publishing process is ready by the time this error occurs, but it seems unclean and hacky. Disabling auto-issue gets rid of the error, but gives a meaningless warning.
My question is: Can I disable the bintray-sbt plugin from build.sbt in some way when posting snapshots? If that doesn't work: how to configure sbt to post to bintray without using bintray-sbt. I never got the url pattern right away when I tried.
source to share
Struggling with the same problem for some time now. Failed 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 note that I have added some keys for the bintray repository configuration. You can set these keys in child projects and override the defaults.
I am using the following properties:
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
source to share