Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

trait Build in package sbt is deprecated: Use .sbt format instead

Tags:

scala

sbt

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.

like image 888
Polymerase Avatar asked Feb 27 '17 14:02

Polymerase


1 Answers

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

like image 193
Seth Tisue Avatar answered Oct 23 '22 04:10

Seth Tisue