Skip to content

Instantly share code, notes, and snippets.

@reikje
Created April 11, 2014 14:43
SBT task to create version.txt
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()}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment