问题
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