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

左心房为你撑大大i 提交于 2019-12-22 06:57:23

问题


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:


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



来源:https://stackoverflow.com/questions/42488840/trait-build-in-package-sbt-is-deprecated-use-sbt-format-instead

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!