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?
We put our projects in an umbrella app. There are pros and cons. Perhaps simplest way..
If I upload it to gitlab to a private repository, will this be possible?
Yes, using the :git options: mix deps — Mix v1.20.2 (see also mix deps.get - Error fetching private repo on GitHub using :github option · Issue #3422 · elixir-lang/elixir · GitHub)
Or if I keep it locally, how will I include it into each of my projects?
Using the :path options mix deps — Mix v1.20.2 (see example at https://stackoverflow.com/questions/28185003/using-a-package-locally-with-hex-pm)
Are there other ways?
Umbrella apps
How can I use that with a private repo?
Per mix deps.get - Error fetching private repo on GitHub using :github option · Issue #3422 · elixir-lang/elixir · GitHub, 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.