如何仅在Play 2.1的命令行上获取应用程序名称和版本 [英] How to get application name and version only on command line in Play 2.1
问题描述
根据此妙招,我正在设置版本,并在控制台中的命令play normalized-name version
之后得到如下输出: /p>
According to this nice trick I'm setting version and after command play normalized-name version
in console get the output like
[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
之类的简明值,或者至少仅获取值myapp
和1.2.3
(无需 Loading info [info] 前缀)我该怎么做?
Anyway for deployment automatization I'd need to get only concated values like myapp-1.2.3
or at least only value myapp
and 1.2.3
(without Loading info [info] prefixes) how can I do this?
推荐答案
我使用SBT 0.13 该功能自Play 2.2起才可用,因此您的里程可能会有所不同.
I use SBT 0.13 that's only available since Play 2.2 so your mileage may vary.
在build.sbt
中定义一个打印出version
设置的任务.
In build.sbt
define a task that prints out the version
setting.
lazy val showVersion = taskKey[Unit]("Show version")
showVersion := {
println(version.value)
}
对其进行调整以包括其他设置,例如normalizedName
(又名normalized-name
).
Tweak it to include other settings like normalizedName
(aka normalized-name
).
使用showVersion
任务,运行以下命令以获取版本:
With the showVersion
task, run the following command to get the version:
$ play --error 'set showSuccess := false' showVersion
0.1-SNAPSHOT
您可能希望将showSuccess := false
添加到build.sbt
以使命令更短-请参见如何关闭信息和成功消息在sbt中?
You may want to add showSuccess := false
to build.sbt
to make the command shorter - see How to turn off info and success messages in sbt?
这篇关于如何仅在Play 2.1的命令行上获取应用程序名称和版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!