4
votes

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?

1
This question initially confused me. You talk about running a mix task escript.build for each project in the umbrella, and then -- when that doesn't work -- you jump to creating a new mix task. Which means, unfortunately, that José's answer doesn't address my problem. Guess I'll open a new one.Roger Lipscombe
I found github.com/vic/mix_under, which is stale, but might help with the original question.Roger Lipscombe

1 Answers

11
votes

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.