Answers:
$ 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的评论):
最近添加了about命令,以尝试简洁地打印最相关的信息,包括sbt版本。
运行命令“ sbt sbt-version”将仅输出当前目录和版本号。
$ sbt sbt-version
[info] Set current project to spark (in build file:/home/morgan/code/spark/)
[info] 0.13.8
在SBT 0.13及更高版本中,您可以使用sbtVersion
任务(由@steffen指出)或about
命令(由@ mark-指出)
在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
您可能需要运行“关于”以阅读其文档:
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
在version
人们似乎期望检查知道SBT版本设置来设置当前模块的版本/修订。
$ 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项目中使用时,任务/设置可能显示不同的输出。
sbt-version
命令行的含义。否则,我不知道sbt-version
命令行和提示符之间的区别。sbtVersion
在两种情况下,它应该是相同的设置。
sbt sbtVersion
在项目外运行需要9秒钟才能运行?Python,node和ruby都需要不到一秒钟的时间,awk,sed,minibloom和许多其他命令行工具也是如此。gcc需要一整秒,非常慢。但是9秒花了樱桃。那个时候sbt在做什么?
您可以使用 sbt about
例: C:\ Users \ smala> sbt关于 [信息]将当前项目设置为smala(在构建文件中:/ C:/ Users / smala /) [info]这是sbt 0.13.6 [信息]当前项目为{文件:/ C:/ Users / smala /} smala 0.1-SNAPSHOT [info]当前项目是针对Scala 2.10.4构建的 [info]可用插件:sbt.plugins.IvyPlugin,sbt.plugins.JvmPlugin,sbt.plugins.CorePlugin,sbt.plugins.JUnitXmlReportPlugin [info] sbt,sbt插件和构建定义正在使用Scala 2.10.4”
从sbt shell中
sbt:venkat> about
[info] This is sbt 1.3.3
...
运行sbt控制台,然后键入sbtVersion
以检查sbt版本和scalaVersion
scala版本
这样做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
您可以使用以下命令检查SBT版本
sbt sbtVersion
sbt about
sbt 'inspect version'
sbt version