Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2016-11-24 16:07:08 +0300
committerPaweł Chmielowski <pchmielowski@process-one.net>2016-11-24 16:23:20 +0300
commit28d0a1b9d22266df228ed96b84128c663777c982 (patch)
tree0c493eb33b76990a2009ce96e77eae0c4c04e08b /rebar.config.script
parent49f1275e2005c8bce2fdcad8499f4fad94a9d768 (diff)
Make compatible with rebar3
Diffstat (limited to 'rebar.config.script')
-rw-r--r--rebar.config.script60
1 files changed, 57 insertions, 3 deletions
diff --git a/rebar.config.script b/rebar.config.script
index 2a924d26c..34e0c328e 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -21,6 +21,14 @@ ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) ->
end,
ModCfg = fun(Cfg, Keys, Op, Default) -> ModCfg0(ModCfg0, Cfg, Keys, Op, Default) end,
+IsRebar3 = case application:get_key(rebar, vsn) of
+ {ok, VSN} ->
+ [VSN1 | _] = string:tokens(VSN, "-"),
+ [Maj, Min, Patch] = string:tokens(VSN1, "."),
+ (list_to_integer(Maj) >= 3);
+ undefined ->
+ lists:keymember(mix, 1, application:loaded_applications())
+ end,
Cfg = case file:consult(filename:join(filename:dirname(SCRIPT), "vars.config")) of
{ok, Terms} ->
Terms;
@@ -121,16 +129,62 @@ TestConfig = case file:read_file_info(TestConfigFile) of
""
end,
+ResolveDepPath = case IsRebar3 of
+ true ->
+ fun("deps/" ++ Rest) ->
+ Slash = string:str(Rest, "/"),
+ Dir = "_build/default/lib/" ++
+ string:sub_string(Rest, 1, Slash-1),
+ Dir ++ string:sub_string(Rest, Slash);
+ (Path) ->
+ Path
+ end;
+ _ ->
+ fun(P) ->
+ P
+ end
+ end,
+
CtIncludes = case lists:keyfind(eunit_compile_opts, 1, Conf1) of
false ->
[];
{_, EunitCompOpts} ->
- [[" -include ", filename:join([Cwd, IncPath])]
+ [[" -include ", filename:join([Cwd, ResolveDepPath(IncPath)])]
|| {i, IncPath} <- EunitCompOpts]
end,
-Conf2 = [{ct_extra_params, lists:flatten(["-ct_hooks cth_surefire ", TestConfig,
- CtIncludes])} | Conf1],
+ProcessErlOpt = fun({i, Path}) ->
+ {i, ResolveDepPath(Path)};
+ (ErlOpt) ->
+ ErlOpt
+ end,
+
+Conf1a = ModCfg(Conf1, [erl_opts],
+ fun(ErlOpts) -> lists:map(ProcessErlOpt, ErlOpts) end, []),
+
+Conf2a = [{ct_extra_params, lists:flatten(["-ct_hooks cth_surefire ", TestConfig,
+ CtIncludes])} | Conf1a],
+
+Conf2 = case IsRebar3 of
+ true ->
+ DepsFun = fun(DepsList) ->
+ lists:filtermap(fun({rebar_elixir_plugin, _, _}) ->
+ false;
+ ({DepName,_, {git,_, _} = Git}) ->
+ {true, {DepName, Git}};
+ (Dep) ->
+ true
+ end, DepsList)
+ end,
+ RB1 = ModCfg(Conf2a, [deps], DepsFun, []),
+ ModCfg(RB1, [plugins], fun(V) -> V -- [deps_erl_opts,
+ rebar_elixir_compiler,
+ rebar_exunit] ++
+ [rebar3_hex] end, []);
+ false ->
+ Conf2a
+ end,
+
Conf3 = case lists:keytake(xref_exclusions, 1, Conf2) of
{value, {_, Items2}, Rest2} ->