簡體   English   中英

sbt使用的默認scalaVersion sbt在哪里?

[英]Where is the default scalaVersion sbt uses?

出於好奇,我想知道sbt使用的默認scalaVersion是否在源代碼中進行了硬編碼? 我的意思是所有未明確指定scala版本的項目的版本(通過scalaVersion設置鍵)

我之所以這樣問是因為,在我的機器上,我正在使用sbt 0.12.4,並且在任何地方(既不是項目根目錄,也不是project~/.sbt/plugins )中都沒有build.sbt文件,當我輸入sbt about我得到了這個:

...
[info] sbt, sbt plugins, and build definitions are using Scala 2.9.2

我已經在使用scala 2.10.2(在我的PATH ),但是我認為此安裝與sbt無關,因為它是從官方倉庫中下載scala的。

有很多類似的問題, 例如thisthis ,但它們僅涉及特定的項目。

有什么想法嗎?

默認情況下,sbt將使用與運行sbt本身相同的Scala版本構建項目。 但是〜/ .sbt / boot目錄從存儲庫下載scala jar,與插件jar相似,因此默認的scala版本是在存儲庫中配置的sbt的依賴項。 意味着隨着sbt版本的前進,因此默認的scala版本也將前進,這是由sbt devs配置的。

可以通過查看plugins / target / resolution-cache / reports / default-global-plugins-scala-tool.xml(以及runtime-resolved.xml中的相同內容)來確認:

<module organisation="org.scala-lang" name="scala-compiler">
<revision name="2.10.2" status="release" pubdate="20130607040625" resolver="sbt-chain" artresolver="sbt-chain" homepage="http://www.scala-lang.org/" downloaded="false" searched="false" default="false" conf="default, optional, compile, runtime, optional(default), master" position="0">
    <license name="BSD-like" url="http://www.scala-lang.org/downloads/license.html    "/>
    <metadata-artifact status="no" details="" size="2843" time="0" location="C:\Users\Bestos\.ivy2\cache\org.scala-lang\scala-compiler\ivy-2.10.2.xml" searched="false" origin-is-local="false" origin-location="http://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.10.2/scala-compiler-2.10.2.pom"/>
    <caller organisation="default" name="global-plugins" conf="scala-tool" rev="2.10.2" rev-constraint-default="2.10.2" rev-constraint-dynamic="2.10.2" callerrev="0.0"/>
    <artifacts>
        <artifact name="scala-compiler" type="jar" ext="jar" status="no" details="" size="14411577" time="0" location="C:\Users\Bestos\.ivy2\cache\org.scala-lang\scala-compiler\jars\scala-compiler-2.10.2.jar">
            <origin-location is-local="false" location="http://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.10.2/scala-compiler-2.10.2.jar"/>
        </artifact>
    </artifacts>
</revision>
</module>

當然,可以通過設置scalaVersion將用於單個項目的scala版本配置為與“ bootstrap scala版本” scalaVersion 在build.sbt中:

scalaVersion := "2.10.1"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM