Make mix task available without compiling first?

Is there a way to make a mix task available without compiling my (umbrella) project first?

I tried making it an .exs file, but that didn’t change anything.

If not, how does Phoenix’s phx.new task work? Where it’s like globally installed somehow and always available?

Thanks!

Is there a way to make a mix task available without compiling my (umbrella) project first?

Make it a dependency. Then it should be available without compiling project.

I tried making it an .exs file, but that didn’t change anything.

Probably if you would load it within mix.exs then it would be available without compiling, but I am not sure there.

how does Phoenix’s phx.new task work?

Do you remember the step mix archive.install phx_new? This is when it is globally installed.


EDIT

Alternatively you can use aliases with functions instead of strings for that.

I’m not sure what you mean. My umbrella looks like this:

umbrella
  apps
     aw
     foo
     bar
     baz

foo, bar, and baz all depend on aw which is where the task is defined.

Thanks!

It need to be completely “external” dependency, that is not part of the umbrella.

2 Likes

When you are in a project, then the project has to be in a compilable state. This is just how mix works.

You can though install tasks globally using archives, the y are not allowed to have any dependencies then. And even though they work from outside of a project, they require you to compile the current project if run from within a project.

2 Likes