4

I'm getting the following set of errors, which I belive is caused by the sbt-assembly plugin that I is used. In fact the object declaration of ;

object Build extends **Build** { (here Build is unresolved).

The error is as follows,

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

A quick resolve is highly appreciated. My Build.scala looks like this.

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
    )
  )
}

Also, I do rekon there is a issue with sbt-assembly upgrades as well which I'm not entirely aware of.

TheShark
  • 420
  • 3
  • 6
  • 17
  • What version of sbt? How does you `Build.scala` look like? – mfirry Sep 22 '17 at 12:22
  • @mfirry My sbt version is 1.0.1 – TheShark Sep 22 '17 at 12:23
  • @mfirry I've edited question with the Build file. – TheShark Sep 22 '17 at 12:27
  • 1
    Per the release notes for SBT 1.0, it looks like support for deprecated build definitions like this have been dropped – time to migrate to build.sbt. See http://www.scala-sbt.org/1.x/docs/Migrating-from-sbt-013x.html – Hugh Sep 22 '17 at 12:29
  • @Hugh I did try out the steps as mentioned there. Now the error is an unresolved dependency pointing to the plugin with a warning on SBT (as if a conflict between 1.0.1 and 1.0.2). – TheShark Sep 22 '17 at 12:56

1 Answers1

2

In sbt version 1.0.x, some key dependencies operators were removed. See the migration docs: https://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html

Here is an short tutorial for writing Build.scala for sbt version 1.0.x: https://alvinalexander.com/scala/sbt-how-to-use-build.scala-instead-of-build.sbt.

You can also refer to build.scala of an existing project for more ref, eg. scalaz.

trompa
  • 1,967
  • 1
  • 18
  • 26
KarateKid
  • 3,138
  • 4
  • 20
  • 39