如何仅在Play 2.1中的命令行上获取应用程序名称和版本

时间:2014-01-15 09:42:04

标签: playframework sbt playframework-2.1

根据this nice trick我在控制台中设置版本和命令后play normalized-name version获取输出

[info] Loading project definition from /www/apps/MyApp/project
[info] Set current project to MyApp (in build file:/www/apps/MyApp/)
[info] myapp
[info] 1.2.3

无论如何,对于部署自动化,我只需要获取myapp-1.2.3或至少只有值myapp1.2.3的合并值(不包含正在加载信息< em> [info] 前缀)我该怎么做?

1 个答案:

答案 0 :(得分:3)

我使用SBT 0.13 that's only available since Play 2.2,因此您的里程可能会有所不同。

build.sbt中定义打印出version设置的任务。

lazy val showVersion = taskKey[Unit]("Show version")

showVersion := {
  println(version.value)
}

调整它以包含其他设置,例如normalizedName(又名normalized-name)。

使用showVersion任务,运行以下命令以获取版本:

$ play --error 'set showSuccess := false' showVersion
0.1-SNAPSHOT

您可能希望将showSuccess := false添加到build.sbt以缩短命令 - 请参阅How to turn off info and success messages in sbt?