* ⇒, →, ← * because we don't want to show them in documentation snippets and then it's complicated to avoid that when snippets are located in src/test/scala in individual modules * dont replace object `→` in FSM.scala and PersistentFSM.scala
39 lines
1,006 B
Scala
39 lines
1,006 B
Scala
/*
|
|
* Copyright (C) 2009-2019 Lightbend Inc. <https://www.lightbend.com>
|
|
*/
|
|
|
|
package akka
|
|
|
|
import java.time.Instant
|
|
import java.time.LocalDateTime
|
|
import java.time.ZoneId
|
|
import java.time.format.DateTimeFormatter
|
|
|
|
import sbt._
|
|
import sbt.Keys._
|
|
|
|
object TimeStampede extends AutoPlugin {
|
|
|
|
override def trigger = noTrigger
|
|
|
|
override lazy val projectSettings = Seq(
|
|
commands += stampVersion)
|
|
|
|
final val Snapshot = "-SNAPSHOT"
|
|
|
|
def stampVersion = Command.command("stampVersion") { state =>
|
|
val extracted = Project.extract(state)
|
|
extracted.appendWithSession(List(version in ThisBuild ~= stamp), state)
|
|
}
|
|
|
|
def stamp(version: String): String = {
|
|
if (version endsWith Snapshot) (version stripSuffix Snapshot) + "-" + timestamp(System.currentTimeMillis)
|
|
else version
|
|
}
|
|
|
|
val formatter = DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss")
|
|
|
|
def timestamp(time: Long): String = {
|
|
formatter.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault()))
|
|
}
|
|
}
|