Mixfile 依赖项中的 runtime: false 是什么意思?

What does `runtime: false` mean in the Mixfile dependencies?

来自 mix deps 文档:

:runtime - whether the dependency is part of runtime applications. If the :applications key is not provided in def application in your mix.exs file, Mix will automatically included all dependencies as a runtime application, except if runtime: false is given. Defaults to true.

根据 mix compile.app 文档:

:applications - all applications your application depends on at runtime. By default, this list is automatically inferred from your dependencies. Mix and other tools use the application list in order to start your dependencies before starting the application itself.

这是否意味着将 runtime: false 添加到依赖项会使它 而不是 作为应用程序监督树的一部分启动,但它的功能将在编译时可用 -时间?

就像你提到的,情况确实如此。标记依赖项 runtime: false 不会在启动主应用程序时将其作为应用程序监督树的一部分启动。

在 Elixir 1.4 之前,我们必须单独指定需要启动的应用程序,方法是将它们放在 applications:

def application do
  [applications: [:logger, :bamboo]]
end

现在我们使用 extra_applications 来代替并标记特定的依赖项 runtime: false 以在运行时将它们从应用程序列表中删除。