summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rebar_app_discover.erl4
-rw-r--r--src/rebar_prv_install_deps.erl12
-rw-r--r--src/rebar_utils.erl12
3 files changed, 15 insertions, 13 deletions
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl
index 0dc062f..df2211e 100644
--- a/src/rebar_app_discover.erl
+++ b/src/rebar_app_discover.erl
@@ -17,12 +17,14 @@ do(State, LibDirs) ->
Apps = find_apps(Dirs, all),
ProjectDeps = rebar_state:deps_names(State),
+ %% Sort apps so we get the same merged deps config everytime
+ SortedApps = rebar_utils:sort_deps(Apps),
lists:foldl(fun(AppInfo, StateAcc) ->
StateAcc1 = merge_deps(AppInfo, StateAcc),
ProjectDeps1 = lists:delete(rebar_app_info:name(AppInfo), ProjectDeps),
rebar_state:project_apps(StateAcc1
,rebar_app_info:deps(AppInfo, ProjectDeps1))
- end, State, Apps).
+ end, State, SortedApps).
format_error({module_list, File}) ->
io_lib:format("Error reading module list from ~p~n", [File]);
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl
index d922522..8db4761 100644
--- a/src/rebar_prv_install_deps.erl
+++ b/src/rebar_prv_install_deps.erl
@@ -44,8 +44,6 @@
-define(PROVIDER, install_deps).
-define(DEPS, [app_discovery]).
--define(APP_NAME_INDEX, 2).
-
-type src_dep() :: {atom(), {atom(), string(), string()}}
| {atom(), string(), {atom(), string(), string()}}.
-type pkg_dep() :: {atom(), binary()} | atom().
@@ -296,7 +294,7 @@ update_src_deps(Profile, Level, SrcDeps, PkgDeps, SrcApps, State, Upgrade, Seen,
end
end,
{[], PkgDeps, SrcApps, State, Seen, Locks},
- sort_deps(SrcDeps)) of
+ rebar_utils:sort_deps(SrcDeps)) of
{[], NewPkgDeps, NewSrcApps, State1, Seen1, _NewLocks} ->
{State1, NewSrcApps, NewPkgDeps, Seen1};
{NewSrcDeps, NewPkgDeps, NewSrcApps, State1, Seen1, NewLocks} ->
@@ -486,14 +484,6 @@ maybe_upgrade(AppInfo, AppDir, true, State) ->
false
end.
-sort_deps(Deps) ->
- %% We need a sort stable, based on the name. So that for multiple deps on
- %% the same level with the same name, we keep the order the parents had.
- %% `lists:keysort/2' is documented as stable in the stdlib.
- %% The list of deps is revered when we get it. For the proper stable
- %% result, re-reverse it.
- lists:keysort(?APP_NAME_INDEX, lists:reverse(Deps)).
-
-spec parse_goal(binary(), binary()) -> pkg_dep().
parse_goal(Name, Constraint) ->
case re:run(Constraint, "([^\\d]*)(\\d.*)", [{capture, [1,2], binary}]) of
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 85f59d6..943c0d7 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -26,7 +26,8 @@
%% -------------------------------------------------------------------
-module(rebar_utils).
--export([droplast/1,
+-export([sort_deps/1,
+ droplast/1,
filtermap/2,
is_arch/1,
sh/2,
@@ -56,11 +57,20 @@
-include("rebar.hrl").
-define(ONE_LEVEL_INDENT, " ").
+-define(APP_NAME_INDEX, 2).
%% ====================================================================
%% Public API
%% ====================================================================
+sort_deps(Deps) ->
+ %% We need a sort stable, based on the name. So that for multiple deps on
+ %% the same level with the same name, we keep the order the parents had.
+ %% `lists:keysort/2' is documented as stable in the stdlib.
+ %% The list of deps is revered when we get it. For the proper stable
+ %% result, re-reverse it.
+ lists:keysort(?APP_NAME_INDEX, lists:reverse(Deps)).
+
droplast(L) ->
lists:reverse(tl(lists:reverse(L))).