Skip to content

Instantly share code, notes, and snippets.

Created December 18, 2012 10:30
Show Gist options
  • Save anonymous/4326949 to your computer and use it in GitHub Desktop.
Save anonymous/4326949 to your computer and use it in GitHub Desktop.
Generate a file containing sbt version information during the build. Using this, you can achieve a very simple version of ktoso/git-commit-id-maven-plugin
val genVersionFile = TaskKey[Unit](
"gen-version-file",
"Generates a file in target containing the apps version"
)
val yapDeploySettings = Seq[Setting[_]](
bump in yap <<= yapBump,
genVersionFile in yap <<= doGenVersionFile
) ++ Seq()
lazy val doGenVersionFile = {
(scalaVersion, baseDirectory, projectID) map { (sv, bd, pid) =>
val buildSbt: File = bd / "build.sbt"
val targetProperties: File = bd / "target" / ("scala-"+sv) / "classes" / "build.version"
versionFrom(buildSbt) match {
case Some(version) =>
replaceFileContent(targetProperties, version)
println("Generated version file in: " + targetProperties.getPath)
case _ =>
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment