我在将项目迁移到 SBT 时遇到问题0.13
。
出于某种原因,来自 SBT 文档的Generate sources的片段对我不起作用。
不幸的是,简单的.sbt
构建定义和 Scala 构建定义都不起作用。项目定义取自文档:
name := "sbt-test"
sourceGenerators in Compile += Def.task {
val file = (sourceManaged in Compile).value / "demo" / "Test.scala"
IO.write(file, """object Test extends App { println("Hi") }""")
Seq(file)
}
编译项目定义时,编译器会报类型错误:
~/P/sbt-test ▶ sbt
[info] Loading global plugins from /Users/phearnot/.sbt/0.13/plugins
[info] Loading project definition from /Users/phearnot/Projects/sbt-test/project
/Users/phearnot/Projects/sbt-test/build.sbt:3: error: No implicit for Append.Value[Seq[sbt.Task[Seq[java.io.File]]], sbt.std.FullInstance.M[Seq[java.io.File]]] found,
so sbt.std.FullInstance.M[Seq[java.io.File]] cannot be appended to Seq[sbt.Task[Seq[java.io.File]]]
sourceGenerators in Compile += Def.task {
^
[error] Type error in expression
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
更新:既然AlexIv已经指出了我的 SBT 文件定义中的问题,我想知道将它移动到 Scala 构建定义中的正确方法是什么?