即使我将scalaVersion设置为2.11.7,我的项目也希望使用Scala 2.10.x进行构建。
每次我重新编译一个新目录时,src / main / scala2.10都出现在我的项目中。我非常确定这必须是SBT重新配置的结果,但究竟是什么造成了这种情况,我该如何解决?
我有一个非常简单的[project_root] /build.sbt文件:
name := "coolproduct"
version := "0.0.1"
lazy val scalaVersion = "2.11.7"
lazy val akkaVersion = "2.4.1"
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % akkaVersion
当我运行此脚本时,似乎正在尝试使用Scala 2.10 - 与我实际要求的完全不同的版本:
> sbt compile
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from C:\Users\salim\workspace\funproxy\project
[info] Set current project to funproxy (in build file:/C:/Users/salim/workspace/funproxy/)
[info] Updating {file:/C:/Users/salim/workspace/funproxy/}funproxy...
[info] Resolving com.typesafe.akka#akka-actor_2.10;2.4.1 ...
[warn] module not found: com.typesafe.akka#akka-actor_2.10;2.4.1
[warn] ==== local: tried
[warn] C:\Users\salim\.ivy2\local\com.typesafe.akka\akka-actor_2.10\2.4.1\ivys\ivy.xml
[warn] ==== jcenter: tried
[warn] https://jcenter.bintray.com/com/typesafe/akka/akka-actor_2.10/2.4.1/akka-actor_2.10-2.4.1.pom
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/typesafe/akka/akka-actor_2.10/2.4.1/akka-actor_2.10-2.4.1.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.akka#akka-actor_2.10;2.4.1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.typesafe.akka:akka-actor_2.10:2.4.1 (C:\Users\salim\workspace\funproxy\build.sbt#L22-23)
[warn] +- default:funproxy_2.10:0.0.1
我正在运行SBT的最新版本:
> sbt about
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from C:\Users\salim\workspace\funproxy\project
[info] Set current project to funproxy (in build file:/C:/Users/salim/workspace/funproxy/)
[info] This is sbt 0.13.8
[info] The current project is {file:/C:/Users/salim/workspace/funproxy/}funproxy 0.0.1
[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
答案 0 :(得分:2)
简短回答:将lazy val scalaVersion = "2.11.7"
更改为:
scalaVersion := "2.11.7"
scalaVersion
不仅仅是您可以覆盖的本地scala var
(或val
);它在内部定义为密钥(see Keys)。使用:=
操作,您将更改该密钥的内部状态。