不推荐使用 sbt 包中的 trait Build:改用 .sbt 格式 [英] trait Build in package sbt is deprecated: Use .sbt format instead

查看:27
本文介绍了不推荐使用 sbt 包中的 trait Build:改用 .sbt 格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用sbt 0.13.5,在IntelliJ中打开项目时出现警告信息

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

~\myproject\project\Build.scala:5: 包 sbt 中的 trait Build已弃用:改用 .sbt 格式

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

Build.scala 的内容是

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: _*)
}

附录:.scala 构建定义 和 <一个 href="http://www.scala-sbt.org/0.13/docs/index.html" rel="noreferrer">sbt 文档 相当多.

如何将我现有的 Build.scala 合并到 build.sbt?感谢您对文档/教程/示例的任何指导.

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

推荐答案

Build.scala 重命名为 build.sbt 并将其向上移动一个目录级别,因此它位于位于顶部而不是 project 目录内.

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: _*)

这是基础.

那么如果你想添加更多的设置,例如:

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

在 sbt 0.13.13 中,您不再需要 :_* 设置序列的东西;旧版本需要它.

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

官方文档中的迁移指南在这里:http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html#Migrating+from+the+Build+trait

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

这篇关于不推荐使用 sbt 包中的 trait Build:改用 .sbt 格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆