Last active
December 12, 2015 10:09
-
-
Save eishay/4756644 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazy val currentVersion: ServiceVersion = current.mode match { | |
case Mode.Test = ServiceVersion("Test mode service") | |
case _ = ServiceVersion(io.Source.fromURL(Play.resource("app_version.txt").get).mkString) | |
} | |
lazy val compilationTime: DateTime = current.mode match { | |
case Mode.Test = currentDateTime | |
case _ = | |
val timeStr = io.Source.fromURL(Play.resource("app_compilation_date.txt").get).mkString | |
DateTimeFormat.forPattern("E, dd MMM yyyy HH:mm:ss Z") | |
.withLocale(Locale.ENGLISH) | |
.withZone(zones.PT).parseDateTime(timeStr) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment