-
Notifications
You must be signed in to change notification settings - Fork 295
Dependency management
Rebar can fetch and build projects including source code from external sources (git, hg, etc.)
It is assumed that these dependencies are available in source form and adhere to the rebar conventions. Moreover, if a project's dependencies have their own dependencies, rebar fetches and builds these transitive dependencies recursively.
Dependencies are defined in the rebar.config
file by the adding the deps
tuple of the following form:
{deps, [Dependency1, Dependency2, ...]}.
Each dependency is defined by a triplet {App, VsnRegex, Source}
where:
- 'App' specifies the OTP application name, either as an atom or a string
- 'VsnRegex' is a string containing a regular expression that must match the OTP application version string
- 'Source' specifies the engine used to fetch the dependency along with an engine specific location:
-
{hg, Url, Rev}
Fetch from mercury repository -
{git, Url}
Fetch from git repository -
{git, Url, {branch, Branch}}
Fetch from git repository -
{git, Url, ""} == {git, Url, {branch, "HEAD"}}
Fetch from git repository -
{git, Url, {tag, Tag}}
Fetch from git repository -
{git, Url, Rev}
Fetch from git repository -
{bzr, Url, Rev}
Fetch from a bazaar repository
-
A dependency specification can have an optional fourth element: [raw]
.
Such dependencies are called "raw" and rebar does not require them
to have a standard Erlang/OTP layout which assumes the presence of either src/dependency_name.app.src
or ebin/dependency_name.app
files.
"Raw" dependencies can still contain rebar.config
and even can have the proper OTP directory
layout, but they won't be compiled.
Only a subset of rebar commands will be executed on the "raw" subdirectories:
get-deps
, update-deps
, check-deps
, list-deps
and delete-deps
.
In rebar.config
:
{deps, [
{em, ".*", {git, "https://github.com/sheyll/erlymock.git"}},
{nano_trace, ".*", {git, "https://github.com/sheyll/nano_trace.git", {branch, "feature/rebar-migration"}}},
{mochiweb, "2.3.2", {git, "https://github.com/mochi/mochiweb.git", {tag, "v2.3.2"}}},
% Or specify a revision to refer a particular commit, useful if the project has only the master branch
% {mochiweb, "2.3.2", {git, "https://github.com/mochi/mochiweb.git", "15bc558d8222b011e2588efbd86c01d68ad73e60"},
% An example of a "raw" dependency:
{rebar, ".*", {git, "git://github.com/rebar/rebar.git", {branch, "master"}}, [raw]}
]}.