diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-02-19 09:21:15 -0500 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-02-19 09:21:15 -0500 |
commit | c3cdecf1252fe51caa7b9aeb0e1f77bd735c0131 (patch) | |
tree | adfcdacac38b87d7612a5757d0efd8d443d285cd /src/rebar_app_discover.erl | |
parent | f203bc3c4fa1727315b96ff0ec4501e35a64e30b (diff) | |
parent | 8874e414a80f7f29e3a8c8f00b3887399a7a6cbc (diff) |
Merge pull request #160 from tsloughter/sub_deps
use project sub-apps with deps in their rebar.config
Diffstat (limited to 'src/rebar_app_discover.erl')
-rw-r--r-- | src/rebar_app_discover.erl | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl index 21dbe1b..df2211e 100644 --- a/src/rebar_app_discover.erl +++ b/src/rebar_app_discover.erl @@ -16,16 +16,35 @@ do(State, LibDirs) -> Dirs = [filename:join(BaseDir, LibDir) || LibDir <- 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(StateAcc, rebar_app_info:deps(AppInfo, ProjectDeps1)) - end, State, Apps). + rebar_state:project_apps(StateAcc1 + ,rebar_app_info:deps(AppInfo, ProjectDeps1)) + end, State, SortedApps). format_error({module_list, File}) -> io_lib:format("Error reading module list from ~p~n", [File]); format_error({missing_module, Module}) -> io_lib:format("Module defined in app file missing: ~p~n", [Module]). +merge_deps(AppInfo, State) -> + Profiles = rebar_state:current_profiles(State), + Name = rebar_app_info:name(AppInfo), + C = rebar_config:consult(rebar_app_info:dir(AppInfo)), + AppState = rebar_state:apply_overrides( + rebar_state:apply_profiles( + rebar_state:new(State, C, rebar_app_info:dir(AppInfo)), Profiles), Name), + lists:foldl(fun(Profile, StateAcc) -> + AppProfDeps = rebar_state:get(AppState, {deps, Profile}, []), + TopLevelProfDeps = rebar_state:get(StateAcc, {deps, Profile}, []), + ProfDeps2 = lists:keymerge(1, TopLevelProfDeps, AppProfDeps), + rebar_state:set(StateAcc, {deps, Profile}, ProfDeps2) + end, State, lists:reverse(Profiles)). + -spec all_app_dirs(list(file:name())) -> list(file:name()). all_app_dirs(LibDirs) -> lists:flatmap(fun(LibDir) -> |