scala 如何找出我使用的是哪个 Play 版本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26409791/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 06:38:18  来源:igfitidea点击:

How to find out which Play version I'm using?

scalaplayframeworktypesafe-activator

提问by joslinm

Kinda silly question, but I used Activatorto get started with the play framework, and now need to see what version I'm using. 2.3 came out with support for docker, but when I put

有点愚蠢的问题,但我使用Activator开始使用 play 框架,现在需要看看我使用的是什么版本。2.3 出来支持 docker,但是当我把

dockerExposedPorts in Docker := Seq(9000, 9443)

dockerExposedPorts in Docker := Seq(9000, 9443)

in my build.sbt, it complains it doesn't know what dockerExposedPorts is, so I'm thinking I might be running 2.2.

在 my 中build.sbt,它抱怨它不知道 dockerExposedPorts 是什么,所以我想我可能正在运行 2.2。

回答by James Davies

Type playVersionwithin the activator console.

playVersion在激活器控制台中键入。

Alternatively you can look in project/plugins.sbtfor the line

或者,您可以查找project/plugins.sbt该行

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.2")

In this example, the play version is 2.3.2

本例中播放版本为2.3.2

回答by Ashutosh Jindal

I use the following to list and highlight all play versions in a play project. Works for a multi-module project as well.

我使用以下内容列出并突出显示播放项目中的所有播放版本。也适用于多模块项目。

The following was tested on macOS Sierra using the default BSD findthat it comes with and GNU grep installed via brew install grep. The latter is required since the following command requires a grep that supports Perl regex (which BSD grep does not).

以下内容是在 macOS Sierra 上使用find它附带的默认 BSD和通过brew install grep. 后者是必需的,因为以下命令需要支持 Perl 正则表达式的 grep(BSD grep 不支持)。

You can check if the grep on your PATH has Perl-regex support by doing this (should show that the -Poption is available):

您可以通过执行此操作检查 PATH 上的 grep 是否具有 Perl-regex 支持(应显示该-P选项可用):

    $ ggrep --help | grep -i Perl
  -P, --perl-regexp         PATTERN is a Perl regular expression

(ggrep is the GNU grep installed via Homebrew)

(ggrep 是通过 Homebrew 安装的 GNU grep)

And now, on to the actual command (note the ggrep in the command):

现在,进入实际命令(注意命令中的ggrep):

   $ find . -name "plugins.sbt" -exec ggrep -PHin --color=always 'com.typesafe.play.*sbt-plugin.*%\s*"\K.*?(?=")' {} \;

which outputs: enter image description here

输出: 在此处输入图片说明

Quick notes about the grep options (extracted from grep help):

关于 grep 选项的快速说明(摘自 grep 帮助):

  -P, --perl-regexp         PATTERN is a Perl regular expression
  -i, --ignore-case         ignore case distinctions
  -n, --line-number         print line number with output lines
  -H, --with-filename       print file name with output lines