scala - 如何在 Play Framework 项目中拆分 build.sbt?

标签 scala sbt

我不确定如何在 Play 项目中拆分 build.sbt 文件。通常在 Play 项目中我只看到一个 build.sbt 文件,但我指的项目除了 build.sbt 文件之外还有多个构建文件,例如:

  1. build.checkstyle.sbt
  2. build.findbugs.sbt
  3. build.junit.sbt

我不确定他们是否已经拆分了 build.sbt 文件,或者是其他文件。谁能帮我理解这里发生了什么?

还有一件事是我知道这些文件的用途是什么,例如 checkstyle 文件用于代码样式检查,junit 文件用于单元测试。这些功能运行得很好,但我很难理解他们是如何/在哪里配置它的。我的意思是这些文件不是由基本 build.sbt 文件导入的,那么配置是如何完成的?

最佳答案

这就是 sbt 的工作原理。它会扫描您的项目中的 .sbt 文件,而不仅仅是 build.sbt 文件。来自 sbt docs :

Any time files ending in .scala or .sbt are used, naming them build.sbt and Build.scala are conventions only. This also means that multiple files are allowed.

因此,基本上,在上述项目中,人们认为最好将设置拆分到不同的文件中。没有什么特别的事情要做,sbt 会为您处理。另一个例子是 Playframework 本身:

https://github.com/playframework/playframework/tree/master/framework

看看它如何拥有 build.sbtversion.sbt 文件。这也只是一个约定,以便您可以在单独的文件中配置项目版本(某些 sbt 插件可以理解,例如 sbt-release)。

关于scala - 如何在 Play Framework 项目中拆分 build.sbt?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41376475/

相关文章:

java - 使用 Proguard 在 dist 上混淆 Play 2 网络应用程序?

scala - SBT 在 Artifactory Maven 存储库中找不到快照

斯卡拉 : Generic method implicit parameter

scala - 如何在其他 RDD 映射方法中使用 RDD?

json - scala play 读取解析嵌套的 json

java - IntelliJ IDEA 中的 scala 包导入错误

sbt - ThisBuild 和 Global 作用域有什么区别?

scala - 如何在 sbt 的 .scala 文件中使用外部依赖?

scala - 为什么 word2vec 只在 Word2Vec.scala :323 处为 mapPartitionsWithIndex 执行一项任务

scala - 如何将配置实例注入(inject)到scalatest?