Skip to content

Instantly share code, notes, and snippets.

@hfs
Created March 13, 2014 11:49
Show Gist options
  • Save hfs/9526953 to your computer and use it in GitHub Desktop.
Save hfs/9526953 to your computer and use it in GitHub Desktop.
sbt-native-packager: Append timestamp to version of Debian package for snapshots
version := "0.2-SNAPSHOT"
// If the version ends with "-SNAPSHOT", let the Debian version end with
// "~SNAPSHOT~yyyyMMddHHmmss". This way updates of the snapshot version can be
// detected by the package manager. Also the tilde "~" sorts before anything
// else when comparing version numbers. This way "1.0" will be regarded newer
// than "1.0~beta".
version in Debian <<= (version) { (v) =>
if (v.endsWith("-SNAPSHOT")) {
val timestampFormat = new java.text.SimpleDateFormat("yyyyMMddHHmmss");
timestampFormat.setTimeZone(java.util.TimeZone.getTimeZone("UTC"));
val now = timestampFormat.format(new java.util.Date());
v.replace("-SNAPSHOT", "~SNAPSHOT~" + now)
} else {
v
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment