I would like to set up an sbt project so that it can publish to the proper artifactory repository based on the (git) branch.
The solution proposed for this question suggests to hardcode the repository in the build.sbt file.
However, I would like the master branch to publish to "releases", and another branch to publish to "snapshots", using the same build.sbt file.
Ideally, I would like the following:
val gitBranch = taskKey[String]("Determines current git branch")
gitBranch := Process("git rev-parse --abbrev-ref HEAD").lines.head
publishTo := {
val myArtifactory = "http://some.where/"
if (gitBranch.value == "master")
Some("releases" at myArtifactory + "releases")
else
Some("snapshots" at myArtifactory + "snapshots")
}
but this yields "error: A setting cannot depend on a task".