如何檢查我正在運行哪個版本的sbt?如何查看sbt版本?
我已經設置了bash的文件使用sbt-launch.jar
,和它的作品,但
$ sbt version
只顯示 「項目版本」(0.1)和
$ sbt --version
什麼都不做。
如何檢查我正在運行哪個版本的sbt?如何查看sbt版本?
我已經設置了bash的文件使用sbt-launch.jar
,和它的作品,但
$ sbt version
只顯示 「項目版本」(0.1)和
$ sbt --version
什麼都不做。
$ 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):最近添加
的有關命令來嘗試簡潔打印 最相關的信息,包括SBT版本。
在SBT 0.13以上,則可以使用sbtVersion
任務(如@steffen指出的)或about
命令(如@標記哈拉指出)
有區別如何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' 來讀它文件:
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啓動程序,如sbt-extras,它覆蓋'sbt-version'的一個命令行的含義。否則,我不知道命令行和提示符處的'sbt-version'有什麼區別。在這兩種情況下它應該是相同的'sbtVersion'設置。 –
有沒有辦法爲不同的子項目設置不同的版本? –
http://stackoverflow.com/questions/20825539/specify-the-version-of-sbt-for-a-subproject –
您可以使用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"
運行命令,「SBT SBT-版」將簡單輸出當前目錄和版本號。
$ sbt sbt-version
[info] Set current project to spark (in build file:/home/morgan/code/spark/)
[info] 0.13.8
'sbt sbtVersion'也有效。 – Razavi
從sbt 1.0開始,你甚至可以*使用'sbt sbtVersion'(camelCase)作爲[連字符分隔名稱被刪除]的支持(http://www.scala-sbt.org/1.x/docs/ SBT-1.0-RELEASE-Notes.html)。 – sschuberth
運行SBT控制檯,然後鍵入sbtVersion
檢查SBT版本,scalaVersion
斯卡拉版
莫非一個--version命令線標誌被考慮?這是人們首先會嘗試的事情。 –
@MattR不能同意你的看法......很奇怪爲什麼這不是sbt作者的第一個想法。 – Ajay
有什麼方法可以爲不同的**子項目**設置不同的版本? –