Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 474
Navaneeth K N Avatar asked Dec 19 '22 16:12

Navaneeth K N


1 Answers

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.

like image 56
José Valim Avatar answered Mar 28 '23 09:03

José Valim