我得到以下错误集,我相信这是由我使用的sbt-assembly插件引起的。 实际上是对象声明;
object Build extends **Build** { (here Build is unresolved).
错误如下,
Error:Error while importing SBT project:<br/><pre>
[info] Loading settings from assembly.sbt,plugins.sbt ...
[info] Loading project definition from C:\Users\ShakthiW\IdeaProjects\TestProject\project
[error] <path>\Build.scala:4:22: not found: type Build
[error] object Build extends Build{
[error] ^
[error] <path>\Build.scala:8:80: value map is not a member of (sbt.TaskKey[sbt.librarymanagement.UpdateReport], sbt.SettingKey[java.io.File], sbt.SettingKey[String])
[error] def copyDepTask = copyDependencies <<= (update, crossTarget, scalaVersion) map {
[error] ^
[error] <path>\Build.scala:19:16: too many arguments (3) for method apply: (id: String, base: java.io.File)sbt.Project in object Project
[error] Note that 'settings' is not a parameter name of the invoked method.
[error] settings = Defaults.defaultSettings ++ Seq(
[error] ^
[error] three errors found
[error] (compile:compileIncremental) Compilation failed
我们非常感谢您的快速解决方案。 我的Build.scala看起来像这样。
import sbt.Keys._
import sbt._
object MyBuild extends Build {
lazy val copyDependencies = TaskKey[Unit]("copy-dependencies")
def copyDepTask = copyDependencies <<= (update, crossTarget, scalaVersion) map {
(updateReport, out, scalaVer) =>
updateReport.allFiles foreach { srcPath =>
val destPath = out / "lib" / srcPath.getName
IO.copyFile(srcPath, destPath, preserveLastModified=true)
}
}
lazy val root = Project(
"root",
file("."),
settings = Defaults.defaultSettings ++ Seq(
copyDepTask
)
)
}
此外,我还认为sbt-assembly升级存在问题,我并不完全清楚。
答案 0 :(得分:2)
在sbt版本1.0.x中,删除了一些关键依赖项运算符。请参阅迁移文档:https://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html
以下是为sbt版本1.0.x编写Build.scala的简短教程:https://alvinalexander.com/scala/sbt-how-to-use-build.scala-instead-of-build.sbt。
您还可以参考现有项目的build.scala以获得更多参考,例如。 scalaz