How to get application name and version only on command line in Play 2.1

南笙酒味 提交于 2019-12-12 16:17:28

问题


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

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?


回答1:


I use SBT 0.13 that's only available since Play 2.2 so your mileage may vary.

In build.sbt define a task that prints out the version setting.

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

showVersion := {
  println(version.value)
}

Tweak it to include other settings like normalizedName (aka normalized-name).

With the showVersion task, run the following command to get the version:

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

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?



来源:https://stackoverflow.com/questions/21133830/how-to-get-application-name-and-version-only-on-command-line-in-play-2-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!