如何仅在Play 2.1的命令行上获取应用程序名称和版本 [英] How to get application name and version only on command line in Play 2.1

查看:76
本文介绍了如何仅在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之类的简明值,或者至少仅获取值myapp1.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆