Would it be possible to append a timestamp to the generated zip's filename you get when executing the dist
command?
Lets say my project name is "backend", and the current dev version is 0.2.3-SNAPSHOT. What I would like to do is execute the dist
command and get a file called backend-0.2.3-SNAPSHOT-20150506.zip.
However, I only want to append the timestamp when doing dist
on a snapshot version, not a production version (0.2.3 for example).
I'm using Play 2.4.0-RC1 and 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
}
Here's what dist
does with version := "1.0-SNAPSHOT"
and version := "1.0"
(removing some noise):
[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
Note that the jar file names aren't affected.