View Source Dependencies
lib-dependencies
Lib Dependencies
Lib Dependencies exist to share non-public code between Ejectable Apps with less ceremony than other mechanisms like private Hex packages.
A Lib Dependency is a directory in the Base
Project's lib
directory that contains a
code library used by Ejectable Apps.
A Lib Dependency is referenced by an atom that matches the name of the
directory in lib
. (lib/utilities
is referenced as :utilities
.)
mix-dependencies
Mix Dependencies
Uniform is aware of the deps in your mix.exs
. Whenever an app is ejected,
Uniform removes all mix dependencies that aren't explicitly needed by the app.
This is accomplished by wrapping your list of dependencies in the following comments:
defp deps do
# uniform:deps
[
...
]
# /uniform:deps
end
adding-dependencies-to-an-app
Adding Dependencies to an App
There are three methods to specify which Lib and Mix dependencies are required by an App:
- Include the dependency for a single Ejectable App by saying so in uniform.exs.
# lib/my_app/uniform.exs
[
lib_deps: [:utilities],
mix_deps: [:absinthe]
]
- Include the dependency in all Ejectable Apps by placing the dependency in the always section of your Blueprint module.
deps do
always do
lib :utilities
mix :absinthe
end
end
- Make it a "sub-dependency" of a dependency from method 1 or 2 by using the
lib_deps
ormix_deps
macros in your deps section. (See "Chained Dependencies" below.)
deps do
lib :some_included_lib do
lib_deps [:utilities]
end
mix :some_included_mix do
mix_deps [:absinthe]
end
end
chained-dependencies
Chained Dependencies
mix uniform.eject
will follow chains of sub-dependencies completely.
Imagine this scenario.
uniform.exs
haslib_deps: [:foo]
- The Blueprint's
deps
saysfoo
haslib_deps: [:bar]
- The Blueprint's
deps
saysbar
haslib_deps: [:baz]
As a result, the ejected codebase will include lib/foo
, lib/bar
, and
lib/baz
.