build.sbt
val Backend = config("backend")
inConfig(Backend)(Defaults.configSettings)
scalaVersion in Backend := "2.11.2-SNAPSHOT"
sbt repl:
> show backend:scalaInstance
[info] Scala instance{version label 2.10.4, actual version 2.10.4, library jar: /home/masgui/.sbt/boot/scala-2.10.4/lib/scala-library.jar, compiler jar: /home/masgui/.sbt/boot/scala-2.10.4/lib/scala-compiler.jar}
> backend:scalaVersion
[info] 2.11.2-SNAPSHOT
当前的工作:
lazy val v = Project(
id = "a",
base = file("woot"),
settings = Project.defaultSettings ++ Seq(
offline := true,
scalaVersion := "2.11.2-SNAPSHOT"
)
)
// ...
scalaInstance in (Backend, Revolver.reStart) := (scalaInstance in v).value
修改
当我向后端添加Classpaths.ivyBaseSettings
时,它会忽略ivyConfigurations += Backend
> show ivyConfigurations
[info] List(..., backend)
但
> backend:update
Cannot add dependency 'com.scalakata#backend_2.11;0.1-20140706T182100' to configuration 'backend' of module com.scalakata#plugin;0.1-20140709T150113 because this configuration doesn't exist!
修改 我用你之前的一个awnser解决了这个问题:Copy a single dependency jar into a folder via build.sbt
答案 0 :(得分:1)
您还必须将Classpaths.ivyBaseSettings
,Classpaths.jvmBaseSettings
和Defaults.compileBase
添加到Backend
配置中。
val Backend = config("backend")
inConfig(Backend)(Classpaths.ivyBaseSettings ++ Classpaths.jvmBaseSettings ++ Defaults.compileBase ++ Defaults.configSettings)
scalaVersion in Backend := "2.11.1"
scalaInstance
配置中的任务Backend
未定义,因此sbt委托默认为scalaInstance
。
[info] Delegates:
[info] backend:scalaInstance
[info] *:scalaInstance
[info] {.}/backend:scalaInstance
[info] {.}/*:scalaInstance
[info] */backend:scalaInstance
[info] */*:scalaInstance
如果您查看其定义的位置,您可以在*:scalaInstance
> inspect definitions scalaInstance
[info]
[info] *:scalaInstance
如果您希望定义它,则必须将Defaults.compileBase
添加到Backend
配置中。
您可以确认它未在Backend
范围内定义。
> inspect definitions scalaInstance
[info]
[info] *:scalaInstance
[info] backend:scalaInstance
但这还不够,如果你检查show backend:scalaInstance
的输出,你会发现它仍然是2.10.x
。
> show backend:scalaInstance
[info] Scala instance{version label 2.11.1, actual version 2.10.4, library jar: /home/lpiepiora/.sbt/boot/scala-2.10.4/lib/scala-library.jar, compiler jar: /home/lpiepiora/.sbt/boot/scala-2.10.4/lib/scala-compiler.jar}
我们需要通过添加Classpaths.ivyBaseSettings ++ Classpaths.jvmBaseSettings
来配置正确的类路径。
show backend:scalaInstance
显示正确的版本。
> show backend:scalaInstance
[info] Scala instance{version label 2.11.1, actual version 2.11.1, library jar: /home/lpiepiora/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.1.jar, compiler jar: /home/lpiepiora/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.1.jar}
[success] Total time: 0 s, completed 08-Jul-2014 20:32:18