Skip to content

Commit 48aa5c0

Browse files
badlopprefiks
authored andcommitted
rebar.config.script: Support relaxed deps (processone/ejabberd#4192)
Instead of adding another element to the tuple, let's reuse the second element, which was used only by rebar2, and always has ".*" as value.
1 parent d6ed645 commit 48aa5c0

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

rebar.config.script

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,31 @@ AppendList = fun(Append) ->
8181
end
8282
end,
8383

84-
Rebar3DepsFilter = fun(DepsList) ->
85-
lists:map(fun({DepName,_, {git,_, {tag,Version}}}) ->
86-
{DepName, Version};
87-
(Dep) ->
88-
Dep
89-
end, DepsList)
90-
end,
84+
% Convert our rich deps syntax to rebar2 format:
85+
% https://github.com/rebar/rebar/wiki/Dependency-management
86+
Rebar2DepsFilter =
87+
fun(DepsList) ->
88+
lists:map(fun({DepName, _HexVersion, Source}) ->
89+
{DepName, ".*", Source}
90+
end, DepsList)
91+
end,
92+
93+
% Convert our rich deps syntax to rebar3 version definition format:
94+
% https://rebar3.org/docs/configuration/dependencies/#dependency-version-handling
95+
% https://hexdocs.pm/elixir/Version.html
96+
Rebar3DepsFilter =
97+
fun(DepsList) ->
98+
lists:map(fun({DepName, HexVersion, {git, _, {tag, GitVersion}} = Source}) ->
99+
case HexVersion == ".*" of
100+
true ->
101+
{DepName, GitVersion};
102+
false ->
103+
{DepName, HexVersion}
104+
end;
105+
({DepName, _HexVersion, Source}) ->
106+
{DepName, ".*", Source}
107+
end, DepsList)
108+
end,
91109

92110
GlobalDepsFilter = fun(Deps) ->
93111
DepNames = lists:map(fun({DepName, _, _}) -> DepName;
@@ -137,6 +155,8 @@ Rules = [
137155
AppendStr("--coverage"), ""},
138156
{[port_env, "CFLAGS"], CfgWithGCov == "true",
139157
AppendStr("--coverage"), ""},
158+
{[deps], (not IsRebar3),
159+
Rebar2DepsFilter, []},
140160
{[deps], IsRebar3,
141161
Rebar3DepsFilter, []},
142162
{[plugins], IsRebar3,

0 commit comments

Comments
 (0)