4

I'm new in both Elixir and Phoenix. Currently I have some concern regarding downloading or using library from private or local mix project. Let say my lib project name is: my_custom_mix_app and its an OTP app using gen_server. And I want it to be able to do just like below snippet from my phoenix app.

defp deps do
    [{:phoenix, "~> 1.2.1"},
    {:phoenix_pubsub, "~> 1.0"},
    {:phoenix_ecto, "~> 3.0"},
    {:mariaex, ">= 0.0.0"},
    {:phoenix_html, "~> 2.6"},
    {:phoenix_live_reload, "~> 1.0", only: :dev},
    {:gettext, "~> 0.11"},
    {:cowboy, "~> 1.0"},
    {:my_custom_mix_app, "~> 1.0"]
end

Well since I came from Java background, I can do that by using Maven or Gradle, even if the lib project happens to be in my local drive, and not registered in any remote Maven repo.

How can I do that in Elixir?

P.S. I checked this article regarding creating Elixir deps, but it doesn't solve my concern on a non registered lib project

Thanks.

Afshin Moazami
  • 2,092
  • 5
  • 33
  • 55
Bromo Programmer
  • 670
  • 2
  • 13
  • 37

2 Answers2

4

There two ways to use internal app dependency

umbrella

defp deps do
    ...
    {:my_app, in_umbrella: true}
end

non-umbrella

defp deps do
    ...
    {:my_app, path: "path/to/the/app"}
    {:my_app_git, git: "https://repo.com/my/app.git}
end

Well documented here https://hexdocs.pm/mix/Mix.Tasks.Deps.html

ardhitama
  • 1,949
  • 2
  • 18
  • 29
  • 1
    The path approach works great when your developing a dependency. The dependency is recompiled anytime you restart your main project. – Steve Pallen Apr 17 '17 at 00:48
1

You can provide the local path to your project by adding a path: key like so:

defp deps do
    ...
    {:my_custom_mix_app, path: "path/to/the/app"}
end
Stephan
  • 2,863
  • 1
  • 17
  • 14