如何查看sbt版本?

时间:2011-12-11 00:27:00

标签: sbt

如何查看我正在运行的sbt版本?

我设置了使用sbt-launch.jar的bash文件,但它可以正常工作,但

$ sbt version

仅显示“项目版本”(0.1)和

$ sbt --version

什么也没做。

9 个答案:

答案 0 :(得分:412)

$ sbt sbtVersion

这将打印当前项目中使用的sbt版本,或者它是否为每个模块的多模块项目。

$ sbt 'inspect sbtVersion'
[info] Set current project to jacek (in build file:/Users/jacek/)
[info] Setting: java.lang.String = 0.13.1
[info] Description:
[info]  Provides the version of sbt.  This setting should be not be modified.
[info] Provided by:
[info]  */*:sbtVersion
[info] Defined at:
[info]  (sbt.Defaults) Defaults.scala:68
[info] Delegates:
[info]  *:sbtVersion
[info]  {.}/*:sbtVersion
[info]  */*:sbtVersion
[info] Related:
[info]  */*:sbtVersion

您可能还想使用sbt about(复制Mark Harrah's comment):

  

最近添加了about命令,试图简洁地打印出来   最相关的信息,包括sbt版本。

答案 1 :(得分:29)

运行命令" sbt sbt-version"将只输出您当前的目录和版本号。

$ sbt sbt-version
[info] Set current project to spark (in build file:/home/morgan/code/spark/)
[info] 0.13.8

答案 2 :(得分:26)

sbt about然后输入以获取SBT版本

enter image description here

答案 3 :(得分:13)

在SBT 0.13及以上版本中,您可以使用sbtVersion任务(由@steffen指出)或about命令(如@ mark-harrah所指出的)

sbtVersion任务在SBT项目内外的工作方式有所不同。在SBT项目中,sbtVersion显示项目及其子项目使用的SBT版本。

$ sbt sbtVersion
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Updating {file:/Users/jacek/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Loading project definition from /Users/jacek/oss/scalania/project
[info] Set current project to scalania (in build file:/Users/jacek/oss/scalania/)
[info] exercises/*:sbtVersion
[info]  0.13.1-RC5
[info] scalania/*:sbtVersion
[info]  0.13.1-RC5

它设置在project/build.properties

jacek:~/oss/scalania
$ cat project/build.properties
sbt.version=0.13.1-RC5

在SBT项目外执行的相同任务显示了可执行文件本身的当前版本。

jacek:~
$ sbt sbtVersion
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Updating {file:/Users/jacek/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to jacek (in build file:/Users/jacek/)
[info] 0.13.0

当你在外面时,about命令似乎更合适,因为它显示了sbt版本以及Scala和可用的插件。

jacek:~
$ sbt about
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Set current project to jacek (in build file:/Users/jacek/)
[info] This is sbt 0.13.0
[info] The current project is {file:/Users/jacek/}jacek 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.2
[info] Available Plugins: com.typesafe.sbt.SbtGit, com.typesafe.sbt.SbtProguard, growl.GrowlingTests, org.sbtidea.SbtIdeaPlugin, com.timushev.sbt.updates.UpdatesPlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.2

您可能希望运行'help about'来阅读其文档:

jacek:~
$ sbt 'help about'
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Set current project to jacek (in build file:/Users/jacek/)
Displays basic information about sbt and the build.

对于sbtVersion设置,inspect命令可以提供帮助。

$ sbt 'inspect sbtVersion'
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Set current project to jacek (in build file:/Users/jacek/)
[info] Setting: java.lang.String = 0.13.0
[info] Description:
[info]  Provides the version of sbt.  This setting should be not be modified.
[info] Provided by:
[info]  */*:sbtVersion
[info] Defined at:
[info]  (sbt.Defaults) Defaults.scala:67
[info] Delegates:
[info]  *:sbtVersion
[info]  {.}/*:sbtVersion
[info]  */*:sbtVersion
[info] Related:
[info]  */*:sbtVersion

人们似乎希望检查以了解SBT版本的version设置是设置当前模块的版本/修订版

$ sbt 'inspect version'
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Set current project to jacek (in build file:/Users/jacek/)
[info] Setting: java.lang.String = 0.1-SNAPSHOT
[info] Description:
[info]  The version/revision of the current module.
[info] Provided by:
[info]  */*:version
[info] Defined at:
[info]  (sbt.Defaults) Defaults.scala:102
[info] Reverse dependencies:
[info]  *:projectId
[info]  *:isSnapshot
[info] Delegates:
[info]  *:version
[info]  {.}/*:version
[info]  */*:version
[info] Related:
[info]  */*:version

在SBT项目中使用时,任务/设置可能会显示不同的输出。

答案 4 :(得分:8)

您可以使用sbt about

Example: 
    C:\Users\smala>sbt about
    [info] Set current project to smala (in build file:/C:/Users/smala/)
    [info] This is sbt 0.13.6
    [info] The current project is {file:/C:/Users/smala/}smala 0.1-SNAPSHOT
    [info] The current project is built against Scala 2.10.4
    [info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin,   sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin
    [info] sbt, sbt plugins, and build definitions are using Scala 2.10.4"

答案 5 :(得分:0)

运行sbt控制台,然后键入sbtVersion以检查sbt版本,并scalaVersion查看scala版本

答案 6 :(得分:0)

执行sbt sbt-version会导致一些错误,例如

[error] Not a valid command: sbt-version (similar: writeSbtVersion, session)
[error] Not a valid project ID: sbt-version
[error] Expected ':'
[error] Not a valid key: sbt-version (similar: sbtVersion, version, sbtBinaryVersion)
[error] sbt-version
[error]            ^

您可以看到提示similar: sbtVersion, version, sbtBinaryVersion,它们都可以工作,但是正确的提示是sbt sbtVersion

生成的

答案 7 :(得分:0)

您可以使用以下命令检查SBT版本

sbt sbtVersion
sbt about
sbt 'inspect version'
sbt version

答案 8 :(得分:0)

在sbt shell内

sbt:venkat> about
[info] This is sbt 1.3.3
...