-
Notifications
You must be signed in to change notification settings - Fork 15
Dependencies
In Erlang/OTP you specify the dependencies of your OTPApplication
in the applications
tuple of the application metadata. This
information is mined to provide a list of applications that are
required by your release.
There is a problem with this though. There is no way to specify version requirements in this application tuple. There is no way to indicate to an app consumer which versions of a dependency are valid with your OTPApplication.
Sinan solves this in two ways. One way is via an extension to the
OTPApplication metadata. The other way is via a similar entry in
the sinan.config
. They both use the exact same syntax that we will
describe below.
To constrain the versions of set of dependencies that you rely on you
must add a dep_constraints
tuple to either the OTPApplication
dotapp file or the sinan.config
. The dep_constraints
tuple
contains a list of dependency constraints for the OTPApplication
in the case of the dotapp or for the entire project in the case of the
sinan.config
. An individual dependency constraint may look as follows.
{<app-name>, <version>, <type>}
or
{<app-name>, <version 1>, <version 2>, <type>}
or
{<app-name>, <version>}
In the above case type may be one of the following
- gte: greater than or equal
- lte: less than or equal
- lt: less than
- gt: greater than
- eql: equal
- between: between two versions
between
is the specifier that takes two versions. So if we depended
on my_app between versions 0.1 and 5.0 we would have the entry:
{my_foo, "0.1", "5.0", between}
that would provide the constraints we need.
The form {<app-name>, <version>}
is exactly equivalent to
{<app-name>, <version>, eql}
and is provided as a convenience.
Lets look at a complete example used in sinan itself. This is from
sinan's sinan.config
.
{dep_constraints,
[{cucumberl, "0.0.4", gte},
{erlware_commons, "0.6.0", gte},
{getopt, "0.0.1", gte}]}.
This is specifying the versions for the entire sinan project.