简体   繁体   中英

How to create a Mix task at the root of an umbrella project?

I have an Elixir umbrella project. Each apps in this project can be compiled into executable file using mix escript.build .

I am trying to run this command from the root of umbrella project and got the following error

** (RuntimeError) Trying to access Mix.Project.app_path for an umbrella project but umbrellas have no app

I understand why this won't work. So tried to create a custom mix task at the root of the umbrella project. Since the root don't have a lib directory, I added one and created a mix task inside it. But that is not listed in mix help .

How can I define a custom mix task at the root of an umbrella project?

Your umbrella projects do not have code. That's because the applications in the umbrella are meant to work regardless if they are inside the umbrella or not. If you want to have a task that is shared across multiple applications, you should define it inside a regular application in the umbrella, like any other, and have the other applications that use the task depend on it, like you would for any other piece of code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM