An sbt plugin for publishing bintray packages.
Consuming or publishing?
This plugin is for publishing. You don't need this plugin to consume Bintray artifacts; sbt supports that directly. If the library you want is published to JCenter (which is like Maven Central, but for Bintray), just add:
resolvers += Resolver.jcenterRepo
Some libraries are published to a particular user's Bintray repo. In that case, do:
resolvers += Resolver.bintrayRepo("otherUser", "maven")
The repo name is typically
"maven" but might be something else.
If you want to publish to Bintray, read on.
What you need
- sbt 0.13.16 or newer
- an account on bintray (get one here)
- a desire to build a more diverse Scala library ecosystem
Add the following to your sbt
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.6")
Note that when specifying
sbt-bintray settings in
project/*.scala files (as opposed to in
build.sbt), you will need to add the following import:
To publish a package to bintray, you need a bintray account. You can register for one here.
BintrayPlugin is an auto plugin that will be added to all projects in your build.
This plugin will upload and release your artifacts into bintray when you run
To exclude a project from being published (for example a root or a tests project) use the
skip in publish := true
At any time you can check who you will be authenticated as with the
bintrayWhoami setting which will print your bintray username
To publish, you need to provide Bintray credentials (user name and API key). There are three ways to set them up: credential file, properties, and environment variables.
- Credentials file
sbt-bintray will look for a credentials file under
~/.bintray/.credentials used to authenticate publishing requests to bintray.
You can interactively set up or change the bintray credentials used by sbt anytime with
Note you will need to
reload your project afterwards which will reset your
You can pass the user and pass as JVM properties when starting sbt:
sbt -Dbintray.user=yourBintrayUser -Dbintray.pass=yourBintrayPass
- Environment variables
sbt-bintray will look for bintray user and pass in the environment variables
You may optionally wish to publish to a bintray organization
instead of your individual bintray user account. To do so, use the
bintrayOrganization setting in your project's build definition.
bintrayOrganization := Some("strength-in-numbers")
By default, a bintray Maven repository for a bintray user or
organization is named
maven. If your Maven repository is named differently, you will need to specify the
bintrayRepository := "oss-maven"
If you want to stage your all artifacts first, put this in your settings:
bintrayReleaseOnPublish in ThisBuild := false
This will break the process into two parts:
- First, stage all artifacts using
- Once all artifacts are staged, run
bintrayReleaseto make the artifacts public
If your project does not use a license, you may opt out of specifying one:
bintrayOmitLicense := true
If your project uses a license, Bintray supports several OSS licenses. If you are new to software licenses you may
want to grab a coffee and absorb some well organized information on the topic of choice.
Sbt already defines a
licenses setting key. In order to use bintray sbt you must define your
licenses key to contain a license with a name matching
one of those bintray defines. I recommend MIT.
licenses += ("MIT", url("http://opensource.org/licenses/MIT"))
The first time you publish a bintray package, this plugin will create the package for you on bintray. Along with the actual contents of the package, you can list a publicly visible list of labels that related to your package.
You can assign this with the
bintrayPackageLabels setting key.
bintrayPackageLabels := Seq("hipster", "keen")
In addition to labels, you can also assign metadata attributes that expose information to package tooling. These can be assigned at the package and the version levels. By default, this plugin assigns a flag indicating "this is an sbt plugin" to the package and the scala version and optionally sbt version to the package version. You can assign these with the
packageAttributes in bintray and
versionAttributes in bintray setting keys. These values must be typed and conform to the types bintray exposes.
// append custom package attributes bintrayPackageAttributes ~= ((_: bintray.AttrMap) ++ Map("my-package-attr" -> Seq(bintry.StringAttr("my-value"))))
// append custom version attributes bintrayVersionAttributes ~= ((_: bintray.AttrMap) ++ Map("my-version-attr" -> Seq(bintry.BooleanAttr(true))))
NOTE This interface will likely change in the future. All changes will be announced and well documented.
Other pieces of flair
When publishing for the first time, bintray sbt will create a package for you under your bintray account's "maven" repository with your project's (module)name as the package name and description for your package description.
It's generally a bad practice to remove a version of a library others may depend on but sometimes you may want test a release with the ability to immediately take it back down if something goes south before others start depending on it. Bintray allows for this flexibility and thus, sbt-bintray does as well. Use the
unpublish task to unpublish the current version from bintray.
Finding your way around
The easiest way to learn about sbt-bintray is to use the sbt shell typing
help bintray to discover bintray keys.
This plugin was first created by Doug Tangren (softprops), 2013-2014.
The plugin is now community-maintained. Releases are published by the sbt team at Lightbend.