How to share private code between projects?

library

#1

I want to share code between my projects by creating a library. Once I’ve create a library, how will I go about adding it to my projects?

If I upload it to gitlab to a private repository, will this be possible?

Or if I keep it locally, how will I include it into each of my projects?

Are there other ways?


#2

We put our projects in an umbrella app. There are pros and cons. Perhaps simplest way…


#3

If I upload it to gitlab to a private repository, will this be possible?

Yes, using the :git options: https://hexdocs.pm/mix/Mix.Tasks.Deps.html#module-git-options-git (see also https://github.com/elixir-lang/elixir/issues/3422)

Or if I keep it locally, how will I include it into each of my projects?

Using the :path options https://hexdocs.pm/mix/Mix.Tasks.Deps.html#module-path-options-path (see example at https://stackoverflow.com/questions/28185003/using-a-package-locally-with-hex-pm)

Are there other ways?

Umbrella apps


#4

How can I use that with a private repo?


#5

Per https://github.com/elixir-lang/elixir/issues/3422, this should work:

{:app_name, git: "git@github.com:YOUR_ACCOUNT/app_name.git"}

assuming you have SSH keys set up to connect to your private repo.