6
votes

Using sbt 0.13.5, when opening the project in IntelliJ, there is a warning message

~\myproject\project\Build.scala:5: trait Build in package sbt is deprecated: Use .sbt format instead

The content of the Build.scala is

import sbt._
object MyBuild extends Build  {
  lazy val root = Project("MyProject", file("."))
    .configs(Configs.all: _*)
    .settings(Testing.settings ++ Docs.settings: _*)
}

The Appendix: .scala build definition and the sbt documentation is rather overwhelming.

How to merge my existing Build.scala to build.sbt? Would appreciate any direction to doc/tutorial/examples.

1
you will have to just move the content of MyBuild to an sbt file (build.sbt is the convention)rogue-one
tried that, got confused by syntax. The Build.scala I tried to convert doesn't have the Key := Value structure as seen in the example shown in the sbt doc.Polymerase
You should be using sbt 0.13.13.Seth Tisue
@SethTisue Just went ahead and upgraded to 0.13.13. All tests passed. Now just need to learn how to migrate the build.scala mentioned above into build.sbtPolymerase

1 Answers

5
votes

Rename Build.scala to build.sbt and move it up one directory level, so it's at the top rather than inside the project directory.

Then strip out the beginning and end, leaving:

lazy val root = Project("MyProject", file("."))
  .configs(Configs.all: _*)
  .settings(Testing.settings ++ Docs.settings: _*)

That's the basics.

Then if you want to add more settings, for example:

lazy val root = Project("MyProject", file("."))
  .configs(Configs.all: _*)
  .settings(
    Testing.settings,
    Docs.settings,
    name := "MyApp",
    scalaVersion := "2.11.8"
  )

You don't need the :_* thing on sequences of settings anymore in sbt 0.13.13; older versions required it.

The migration guide in the official doc is here: http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html#Migrating+from+the+Build+trait