lazy val branchName = settingKey[String]("The name of the Github branch which will prefix the RPM")

branchName := sys.props.getOrElse("branchName", sys.env.getOrElse("branchName", "master"))

lazy val rpmPrepare = taskKey[Unit]("Executes steps which are needed before the RPM can be build")

rpmPrepare := {
    val dir = Paths.get("build")
    val versionFile = dir.resolve("version.txt")
    Files.deleteIfExists(versionFile)
    Files.createFile(versionFile)
    Some(new PrintWriter(versionFile.toFile)).foreach{p => p.write("%s_%s".format(branchName.value, version.value)); p.close()}
}