我想创建一个执行传递本地的任务,然后将.xml文件的副本复制到项目根目录中的ivy.xml。我希望它可以从每个sbt命令行获得,所以我把它放在〜/ .sbt / 0.13 / plugins中。
我对如何引用deliverLocal中的值感到困惑。如果我这样做:
import sbt._
import Keys._
object JivyBuild extends Build {
lazy val jivy = TaskKey[String] ( "jivy", "Copy the ivy file created by deliverLocal to ivy.xml" )
lazy val jivyTask = jivy := {
val ivyFile = deliverLocal.value
com.google.common.io.Files.copy(ivyFile, baseDirectory.value / "ivy.xml")
println(s"base dir is " + baseDirectory.value.toString)
ivyFile.toString
}
override lazy val settings = super.settings ++
Seq(jivyTask, resolvers := Seq())
lazy val root = Project(id = "root",
base = file("."),
settings = Project.defaultSettings ++ settings)
}
当我开始sbt:
时出现此错误[error] Reference to undefined setting:
[error]
[error] {.}/*:deliverLocal from {.}/*:jivy (/Users/james/.sbt/0.13/plugins/Jivy.scala:8)
[error] Did you mean *:deliverLocal ?
[error]
[error] Use 'last' for the full log.
答案 0 :(得分:3)
您正在覆盖默认设置,因此deliverLocal设置被删除。不要改变:
override lazy val settings = super.settings ++
Seq(jivyTask, resolvers := Seq())
类似于:
lazy val mysettings = super.settings ++
Seq(jivyTask, resolvers := Seq())
在root中引用它而不是settings
:
lazy val root = Project(id = "root",
base = file("."),
settings = Project.defaultSettings ++ mysettings)