-
Notifications
You must be signed in to change notification settings - Fork 20
/
mix.exs
56 lines (45 loc) · 1.56 KB
/
mix.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
defmodule Khepri.MixProject do
use Mix.Project
def project do
# To avoid duplication, we query the app file to learn the application
# name, description and version.
{:ok, [app]} = :file.consult("src/khepri.app.src")
{:application, app_name, props} = app
description = to_string(Keyword.get(props, :description))
version = to_string(Keyword.get(props, :vsn))
[
app: app_name,
description: description,
version: version,
language: :erlang,
deps: deps()
]
end
def application do
{:ok, [app]} = :file.consult("src/khepri.app.src")
{:application, _app_name, props} = app
Keyword.take(props, [:applications, :env, :mod, :registered])
end
defp deps() do
# To avoid duplication, we query rebar.config to get the list of
# dependencies and their version pinning.
{:ok, terms} = :file.consult("rebar.config")
deps = Keyword.get(terms, :deps)
# The conversion to the mix.exs expected structure is basic, but that
# should do it for our needs.
for {app_name, version} <- deps do
case version do
_ when is_list(version) ->
{app_name, to_string(version)}
{:git, url} ->
{app_name, git: to_string(url)}
{:git, url, {:ref, ref}} ->
{app_name, git: to_string(url), ref: to_string(ref)}
{:git, url, {:branch, branch}} ->
{app_name, git: to_string(url), branch: to_string(branch)}
{:git, url, {:tag, tag}} ->
{app_name, git: to_string(url), tag: to_string(tag)}
end
end
end
end