I want to install a version of the project, which depends on the git branch, in order to have the current major version + the current date in the development version and just a large number in production. Therefore, I completed a task that calculates the version I need:
val projectVersion = taskKey[String]("Compute project version") projectVersion := { val v = version.value // get Major version number val date = new SimpleDateFormat("yyyyMMdd").format(new Date) if (isDev.value) v + "-" + date else v }
isDev
is another task that returns Task[Boolean]
, indicating that it is a branch with a non-master:
branch := Process("git rev-parse --abbrev-ref HEAD").lines.headOption isDev := branch.value != "master"
then I tried to install the computed version on version
:
version := Versioning.projectVersion.value
But this is forbidden:
BuildSettings.scala:15: A setting cannot depend on a task
What is the right way to do this?
user1078671
source share