凤凰伞编译顺序

Sam*_*ton 3 macros elixir phoenix-framework

我有一个包含 3 个应用程序的伞形项目:main_web,mainchild.

我定义了main一个child应用程序使用的宏。

编译时,我有时会收到一个错误,说当我再次运行相同的命令时Main.MyMacro未定义some_file_in_child_app.ex,一切都很好。

我认为这是由于some_file_in_child_app.ex在编译之前尝试使用宏。

确保Main.MyMacro加载并避免此错误的好方法是什么?

我不确定沿着跑步mix compile apps/main路线走是否正确

Jos*_*lim 5

如果您的伞形应用程序之间存在依赖关系,则需要明确列出它们。

您应该将其添加到apps/child/mix.exs

def deps do
  [
    # ... other deps ...
    {:main, in_umbrella: true}
  ]
end
Run Code Online (Sandbox Code Playgroud)

现在 Mix 将确保在编译main之前先编译child