Skip to content

Commit 4ca0383

Browse files
authored
Update project.ex
1 parent c6aaa80 commit 4ca0383

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

lib/mix/lib/mix/project.ex

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,26 +150,46 @@ defmodule Mix.Project do
150150
The pattern of keeping multiple applications in the same repository is known as
151151
[monorepo](https://en.wikipedia.org/wiki/Monorepo). Umbrella projects maximize
152152
this pattern by providing conveniences to compile, test and run multiple
153-
applications at once.
153+
applications at once. When an umbrella application needs to depend on another
154+
one, it can be done by passing the `in_umbrella: true` option to your dependency.
155+
If an umbrella application `:foo` depends on its sibling `:bar`, you can specify
156+
this dependency in `foo`'s `mix.exs` file as:
154157
155-
### Breaking umbrellas apart
158+
{:bar, in_umbrella: true}
159+
160+
### Undoing umbrellas
156161
157162
Using umbrella projects can impact how you design and write your software and,
158-
as time passes, they may turn our to be the right or the wrong choice.
163+
as time passes, they may turn out to be the wrong choice.
159164
If you find yourself in a position where you want to use different configurations
160165
in each application for the same dependency or use different dependency versions,
161166
then it is likely your codebase has grown beyond what umbrellas can provide.
162167
163-
The good news is that breaking an umbrella apart is quite straightforward,
164-
as you simply need to move applications outside of the umbrella project's
165-
`apps/` directory and update the project's `mix.exs` file to no longer set
166-
the `build_path`, `config_path`, `deps_path`, and `lockfile` configuration.
167-
You can depend on private projects outside of the umbrella in multiple ways:
168-
169-
1. Move it to a separate folder within the same repository and point to
170-
it using a path dependency (the monorepo pattern)
171-
2. Move the repository to a separate Git repository and depend on it
172-
3. Publish the project to a private [Hex.pm](https://hex.pm/) organization
168+
If you find yourself in this situation, you have two options:
169+
170+
1. Convert everything into a single Mix project, which can be done in steps.
171+
First move all files in `lib`, `test`, `priv`, and friends into a single
172+
application, while still keeping the overall umbrella structure and
173+
`mix.exs` files. For example, if you umbrellas has three applications,
174+
`foo`, `bar` and `baz`, where `baz` depends on both `foo` and `bar`,
175+
move all source to `baz`. Then remove `foo` and `bar` one by one,
176+
updating any configuration and removing references to the `:foo` and
177+
`:bar` application names. Until you have only a single application.
178+
179+
2. Remove umbrella structure while keeping them as distinct applications.
180+
This is done by removing moving applications outside of the umbrella
181+
project's `apps/` directory and updating the projects' `mix.exs` files
182+
to no longer set the `build_path`, `config_path`, `deps_path`, and
183+
`lockfile` configurations, guaranteeing each of them have their own
184+
build and dependency structure.
185+
186+
Keep in mind that umbrellas are one of many options for managing private
187+
packages within your organization. You might:
188+
189+
1. Have multiple directories inside the same repository and using `:path`
190+
dependencies (which is essentially the monorepo pattern)
191+
2. Use private Git repositories and Mix' ability to fetch Git dependencies
192+
3. Publishing packages to a private [Hex.pm](https://hex.pm/) organization
173193
174194
## Invoking this module
175195

0 commit comments

Comments
 (0)