如何使用 SBT 打印项目构建的测试配置中的所有设置?

How can I print all the settings in Test configuration for a project build using SBT?

我有一个 scala-js 项目,添加了一个特定的库依赖项,影响了项目测试用例的方式 运行。没有库依赖,一切都很好,当我添加它们时,测试不会执行。我想检查所有 sbt 设置,如果它们受到影响。有什么办法可以打印所有设置并检查吗?

BuildStructure.data seems to give access to all the settings by scope. We could access it by defining a custom command printAllTestSettings 像这样:

def printAllTestSettings = Command.command("printAllTestSettings") { state =>
  val structure = Project.extract(state).structure

  val testScope =
    Scope(
      Select(ProjectRef(new File("/home/mario/sandbox/hello-world-scala/"), "root")),
      Select(ConfigKey("test")),
      Zero,
      Zero
    )

  structure
    .data
    .keys(testScope)
    .foreach(key => println(s"${key.label} = ${structure.data.get(testScope, key).get}"))

 state
}

commands ++= Seq(printAllTestSettings)

这是输出片段:

...
managedSourceDirectories = List(/home/mario/sandbox/hello-world-scala/target/scala-2.12/src_managed/test)
managedResourceDirectories = List(/home/mario/sandbox/hello-world-scala/target/scala-2.12/resource_managed/test)
testLoader = Task((taskDefinitionKey: ScopedKey(Scope(Select(ProjectRef(file:/home/mario/sandbox/hello-world-scala/,root)), Select(ConfigKey(test)), Zero, Zero),testLoader)))
packageBin = Task((taskDefinitionKey: ScopedKey(Scope(Select(ProjectRef(file:/home/mario/sandbox/hello-world-scala/,root)), Select(ConfigKey(test)), Zero, Zero),packageBin)))
...