@@ -30,10 +30,12 @@ Cfg = case file:consult(filename:join([filename:dirname(SCRIPT),"vars.config"]))
3030{ldflags , CfgLDFlags } = lists :keyfind (ldflags , 1 , Cfg ),
3131{with_gcov , CfgWithGCov } = lists :keyfind (with_gcov , 1 , Cfg ),
3232
33- IsRebar3 = case erlang :function_exported (rebar3 , main , 1 ) of
34- true ->
35- true ;
36- _ ->
33+ IsRebar3 = case application :get_key (rebar , vsn ) of
34+ {ok , VSN } ->
35+ [VSN1 | _ ] = string :tokens (VSN , " -" ),
36+ [Maj |_ ] = string :tokens (VSN1 , " ." ),
37+ (list_to_integer (Maj ) >= 3 );
38+ undefined ->
3739 lists :keymember (mix , 1 , application :loaded_applications ())
3840 end ,
3941
@@ -77,13 +79,31 @@ AppendList = fun(Append) ->
7779 end
7880 end ,
7981
80- Rebar3DepsFilter = fun (DepsList ) ->
81- lists :map (fun ({DepName ,_ , {git ,_ , {tag ,Version }}}) ->
82- {DepName , Version };
83- (Dep ) ->
84- Dep
85- end , DepsList )
86- end ,
82+ % Convert our rich deps syntax to rebar2 format:
83+ % https://github.com/rebar/rebar/wiki/Dependency-management
84+ Rebar2DepsFilter =
85+ fun (DepsList ) ->
86+ lists :map (fun ({DepName , _HexVersion , Source }) ->
87+ {DepName , " .*" , Source }
88+ end , DepsList )
89+ end ,
90+
91+ % Convert our rich deps syntax to rebar3 version definition format:
92+ % https://rebar3.org/docs/configuration/dependencies/#dependency-version-handling
93+ % https://hexdocs.pm/elixir/Version.html
94+ Rebar3DepsFilter =
95+ fun (DepsList ) ->
96+ lists :map (fun ({DepName , HexVersion , {git , _ , {tag , GitVersion }} = Source }) ->
97+ case HexVersion == " .*" of
98+ true ->
99+ {DepName , GitVersion };
100+ false ->
101+ {DepName , HexVersion }
102+ end ;
103+ ({DepName , _HexVersion , Source }) ->
104+ {DepName , " .*" , Source }
105+ end , DepsList )
106+ end ,
87107
88108GlobalDepsFilter = fun (Deps ) ->
89109 DepNames = lists :map (fun ({DepName , _ , _ }) -> DepName ;
0 commit comments