How to add classifier to dependencies and publish with git branch name?

For an sbt/Scala/Play project:

I would like to use the current branch name and add that as a classifier for the dependency resolutions. If it's not a particular branch then I'd like to default with no classifiers.

Also the repo should publish its branch name as classifier.

I.e. If I am on develop branch, all internal dependencies should resolve with classifier develop and if on any other branch it should resolve with no classifiers.

Also for publish, based on the branch I'd like to add branch name if needed.

Any help would be appreciated.


I encountered the same problem. I ended up using the above approach, i.e. using: def branch() = "git rev-parse --abbrev-ref HEAD" !! And in the version: version := branch + "-0.0.3-SNAPSHOT",

Pay attention though that you need two exclamation mark and not one (the one return the command returns code).

Now I can use it as resolver in artifactory (and to distinct between different branches).

What about having a def to generate ModuleIDs for your dependencies in libraryDependencies that uses git rev-parse --abbrev-ref HEAD under the covers?

Use the following in a build.sbt build definition as a gentle start. Use show libraryDependencies to print out the dependencies with branch added.

def branch() = "git rev-parse --abbrev-ref HEAD" !

def dependency(g: String, m: String, v: String): ModuleID = {
    g %% m % s"$v-${branch()}"

libraryDependencies += dependency("com.typesafe.akka", "akka-actor", "2.3.4")

You may also be quite successful with A GIT plugin for SBT.

Need Your Help

SQL Server logins and users -- assign multiple logins to a single user?

sql-server permissions security ssms

In SSMS, since I can't assign multiple login objects to a single user object, what is a best practice to achieve an equivalent security model?

Reduce array with mask and np.where and calculate with it

python numpy

Let's say I have the following arrays (in reality it is a KxNxM masked array with 1514764800 fields stored like:, mask=mask, dtype=np.float32)):