将时间戳添加到由 sbt-native-packager 创建的 zip

Add timestamp to zip created by sbt-native-packager

是否可以在执行 dist 命令时获得的生成的 zip 文件名中附加时间戳?

假设我的项目名称是"backend",当前的开发版本是0.2.3-SNAPSHOT。我想做的是执行 dist 命令并获取一个名为 backend-0.2.3-SNAPSHOT-20150506.zip 的文件。 但是,我只想在快照版本上执行 dist 时附加时间戳,而不是生产版本(例如 0.2.3)。

我正在使用 Play 2.4.0-RC1 和 sbt 0.13.8

 import com.typesafe.sbt.packager.Keys._

 packageName in Universal := {
   val name = (packageName in Universal).value
   def timestamp = new java.text.SimpleDateFormat("yyyyMMdd") format new java.util.Date()
   if (isSnapshot.value) s"$name-$timestamp" else name
 }

下面是 distversion := "1.0-SNAPSHOT"version := "1.0" 所做的(去除一些噪音):

 [play-scala] $ dist
 [info] Packaging /Users/dnw/Desktop/play-scala/target/scala-2.11/play-scala_2.11-1.0-SNAPSHOT-sources.jar ...
 [info] Wrote /Users/dnw/Desktop/play-scala/target/scala-2.11/play-scala_2.11-1.0-SNAPSHOT.pom
 [info] Packaging /Users/dnw/Desktop/play-scala/target/scala-2.11/play-scala_2.11-1.0-SNAPSHOT-web-assets.jar ...
 [info] Packaging /Users/dnw/Desktop/play-scala/target/scala-2.11/play-scala_2.11-1.0-SNAPSHOT-javadoc.jar ...
 [info] Packaging /Users/dnw/Desktop/play-scala/target/scala-2.11/play-scala_2.11-1.0-SNAPSHOT.jar ...
 [info]
 [info] Your package is ready in /Users/dnw/Desktop/play-scala/target/universal/play-scala-1.0-SNAPSHOT-20150506.zip

 [play-scala] $ set version := "1.0"
 [info] Defining *:version

 [play-scala] $ dist
 [info] Packaging /Users/dnw/Desktop/play-scala/target/scala-2.11/play-scala_2.11-1.0-sources.jar ...
 [info] Wrote /Users/dnw/Desktop/play-scala/target/scala-2.11/play-scala_2.11-1.0.pom
 [info] Packaging /Users/dnw/Desktop/play-scala/target/scala-2.11/play-scala_2.11-1.0-web-assets.jar ...
 [info] Packaging /Users/dnw/Desktop/play-scala/target/scala-2.11/play-scala_2.11-1.0-javadoc.jar ...
 [info] Packaging /Users/dnw/Desktop/play-scala/target/scala-2.11/play-scala_2.11-1.0.jar ...
 [info]
 [info] Your package is ready in /Users/dnw/Desktop/play-scala/target/universal/play-scala-1.0.zip

请注意,jar 文件名不受影响。