找不到:类型构建(未解析'构建')

问题描述 投票:2回答:1

我收到了以下错误,我认为这是由我使用的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
    )
  )
}

此外,我确实rekon有一个问题,我还没有完全意识到sbt-assembly升级。

scala sbt-assembly
1个回答
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

© www.soinside.com 2019 - 2024. All rights reserved.