Skip to content

Instantly share code, notes, and snippets.

@eishay
Created May 2, 2016 22:37
Show Gist options
  • Save eishay/90a62962033ea65b1be700980e614884 to your computer and use it in GitHub Desktop.
Save eishay/90a62962033ea65b1be700980e614884 to your computer and use it in GitHub Desktop.
import org.joda.time.{DateTime, DateTimeZone, LocalDate, LocalTime}
import org.joda.time.format.DateTimeFormat
...
val BUILD_DATETIME_FORMAT = DateTimeFormat.forPattern("yyyyMMdd-HHmm")
.withLocale(Locale.ENGLISH)
.withZone(DateTimeZone.forID("America/Los_Angeles"))
val buildTime = BUILD_DATETIME_FORMAT.print(new DateTime(DateTimeZone.forID("America/Los_Angeles")))
val appVersion = "%s-%s-%s".format(buildTime,
"git rev-parse --abbrev-ref HEAD".!!.trim, "git rev-parse --short HEAD".!!.trim)
val PT = DateTimeZone.forID("America/Los_Angeles")
val now = DateTimeFormat.forPattern("E, dd MMM yyyy HH:mm:ss Z")
.withLocale(Locale.ENGLISH).withZone(PT).print(new DateTime(PT))
def writeToFile(fileName: String, value: String) = {
val file = new PrintWriter(new File(fileName))
try { file.print(value) } finally { file.close() }
}
writeToFile("conf/app_version.txt", appVersion)
writeToFile("conf/app_compilation_date.txt", now)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment