【问题标题】:Is it possible to see sbt's execution plan?可以看到sbt的执行计划吗?
【发布时间】:2014-12-29 10:22:06
【问题描述】:

sbt 构建配置可能会变得相当复杂。当它发生时,很难确切地说出 sbt 会做什么,因为你不确定你在构建定义中做了正确的事情。如果您有一个大型项目,运行完整的构建和测试周期来测试更改真的很痛苦而且很慢。

例如,我正在配置 sbt 以并行构建和测试我的项目。如果我能要求 sbt 报告那就太好了:

  • 具体分叉多少 JVM 以及何时分叉
  • 每个 JVM 将被分配的确切选项
  • 确切地说哪些任务将分配给每个 JVM
  • 测试在 JVM 中的确切分组方式

也许其中一些信息只能通过做一些工作来确定,甚至可能通过执行完整的构建和测试来确定。但是,如果有某种简洁的报告清楚地说明正在发生的事情,那就太好了。

sbt 是否提供这样的设施?

【问题讨论】:

  • @Jacek - JVM 的配置和测试/任务的分配是某人可能希望查看计划的示例,但执行计划可能还有其他用例。 (此外,该示例提到了每个 JVM 的任务数,而不是相反。)

标签: sbt


【解决方案1】:

我认为这在 sbt 中不容易实现。

inspect 命令可以告诉你很多你需要什么,但与你所追求的相比,这只是一小部分,而且还缺少很多完整的计划。

> help inspect
inspect <key>

    For a plain setting, the value bound to the key argument is displayed using its toString method.
    Otherwise, the type of task ("Task" or "Input task") is displayed.

    "Dependencies" shows the settings that this setting depends on.

    "Reverse dependencies" shows the settings that depend on this setting.

    When a key is resolved to a value, it may not actually be defined in the requested scope.
    In this case, there is a defined search sequence.
    "Delegates" shows the scopes that are searched for the key.
    "Provided by" shows the scope that contained the value returned for the key.

    "Related" shows all of the scopes in which the key is defined.

inspect tree <key>

    Displays `key` and its dependencies in a tree structure.
    For settings, the value bound to the setting is displayed and for tasks, the type of the task is shown.

inspect uses <key>

    Displays the settings and tasks that directly depend on `key`.

inspect definitions <key>

    Displays the scopes in which `key` is defined.

阅读Inspect the build 了解该命令。

您可能还想将showforkjavaOptions 等设置一起使用:

> help fork
If true, forks a new JVM when running.  If false, runs in the same JVM as the build.

> help javaOptions
Options passed to a new JVM when forking.

参见官方文档中的Forking

我也想要这样的工具。

【讨论】:

  • inspect 看起来是一个有用的工具。您是否可以提供inspect 的用法示例,以显示示例中提到的一些信息?
猜你喜欢
  • 2013-10-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-23
  • 2012-08-01
相关资源
最近更新 更多