为什么带有ScalaVersion的sbt项目也设置为2.11加载2.10

时间:2015-08-25 16:25:36

标签: scala sbt scalatra

以下是scalatra / spark项目project/build.sbt的核心:

  val ScalaVersion = "2.11.6"
  val ScalatraVersion = "2.4.0-RC2-2"

//   ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true)}
  lazy val project = Project (
    "keywordsservlet",
    file("."),
    settings = ScalatraPlugin.scalatraSettings ++ scalateSettings ++ Seq(
      organization := Organization,
      name := Name,
      version := Version,
      scalaVersion := ScalaVersion,
      resolvers += Classpaths.typesafeReleases,
      resolvers += "Scalaz Bintray Repo" at "http://dl.bintray.com/scalaz/releases",
      libraryDependencies ++= Seq(
//        "org.scala-lang" % "scala-reflect" % ScalaVersion,
        "org.apache.spark" % "spark-core_2.11" % "1.4.1",
        "org.scalatra" %% "scalatra" % ScalatraVersion,
        "org.scalatra" %% "scalatra-scalate" % ScalatraVersion,
        "org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
        "ch.qos.logback" % "logback-classic" % "1.1.2" % "runtime",
        "org.eclipse.jetty" % "jetty-webapp" % "9.2.10.v20150310" % "container",
        "javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided"
      ),

这是sbt输出:注意它正在加载2.10目标!

$ sbt   

[info] Loading project definition from /shared/keywords/project
[info] Updating {file:/shared/keywords/project/}keywords-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 1 Scala source to /shared/keywords/project/target/scala-2.10/sbt-0.13/classes...
[info] Set current project to KeywordsServlet (in build file:/shared/keywords/)

那么这里发生了什么?

1 个答案:

答案 0 :(得分:4)

您用于项目的Scala版本与sbt本身使用的Scala版本之间存在差异。

sbt 0.13可以编译2.9,2.10和2.11(以及2.12)。但是,当它编译build.sbt或Build.scala文件时,sbt 0.13使用Scala 2.10。

同样,sbt使用的所有插件都是用2.10编译的。

另一方面,sbt 0.12使用了Scala 2.9。