Skip to content

Commit 072b3eb

Browse files
committed
Add a is_umbrella config option
1 parent d039292 commit 072b3eb

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/rebar.hrl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414

1515
-define(DEFAULT_BASE_DIR, "_build").
1616
-define(DEFAULT_ROOT_DIR, ".").
17-
-define(DEFAULT_PROJECT_APP_DIRS, ["apps/*", "lib/*", "."]).
17+
-define(DEFAULT_PROJECT_APP_DIRS, ["apps/*", "lib/*", ".", "src/*"]).
1818
-define(DEFAULT_PROJECT_PLUGIN_DIRS, ["plugins/*"]).
19+
-define(DEFAULT_UMBRELLA, false).
1920
-define(DEFAULT_CHECKOUTS_DIR, "_checkouts").
2021
-define(DEFAULT_CHECKOUTS_OUT_DIR, "checkouts").
2122
-define(DEFAULT_DEPS_DIR, "lib").

src/rebar_plugins.erl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ discover_plugins(State) ->
221221
end.
222222

223223
is_umbrella(State) ->
224+
io:format(" +++ rebar_state:get(State, is_umbrella):~p~n~n", [rebar_state:get(State, is_umbrella, ?DEFAULT_UMBRELLA)]),
224225
%% We can't know if this is an umbrella project before running app discovery,
225226
%% but plugins are installed before app discovery. So we do a heuristic.
226227
%% The lib dirs we search contain things such as apps/, lib/, etc.
@@ -231,16 +232,24 @@ is_umbrella(State) ->
231232
%% So what we do here is look for the library directories without the ".",
232233
%% and if none of these paths exist but one of the src_dirs exist, then
233234
%% we know this is not an umbrella application.
234-
case rebar_dir:lib_dirs(State) of
235-
?DEFAULT_PROJECT_APP_DIRS ->
235+
case rebar_state:get(State, is_umbrella, ?DEFAULT_UMBRELLA) of
236+
?DEFAULT_UMBRELLA ->
236237
Root = rebar_dir:root_dir(State),
237238
LibPaths = lists:usort(rebar_dir:lib_dirs(State)) -- ["."],
238239
SrcPaths = rebar_dir:src_dirs(rebar_state:opts(State), ["src"]),
240+
io:format(" +++ Root:~p~n~n", [Root]),
241+
io:format(" +++ LibPaths:~p~n~n", [LibPaths]),
242+
io:format(" +++ SrcPaths:~p~n~n", [SrcPaths]),
243+
io:format(" +++ rebar_dir:src_dirs(rebar_state:opts(State), [src]):~p~n~n", [rebar_dir:src_dirs(rebar_state:opts(State), ["src"])]),
244+
io:format(" +++ lists:map(fun(Dir) -> filelib:wildcard(filename:join(Root, Dir)) end, LibPaths):~p~n~n", [lists:map(fun(Dir) -> filelib:wildcard(filename:join(Root, Dir)) end, LibPaths)]),
245+
io:format(" +++ lists:map(fun(Dir) -> filename:join(Root, Dir) end, SrcPaths):~p~n~n", [lists:map(fun(Dir) -> filename:join(Root, Dir) end, SrcPaths)]),
246+
io:format(" +++ lists:any(fun(Dir) -> [] == filelib:wildcard(filename:join(Root, Dir)) end, LibPaths):~p~n~n", [lists:any(fun(Dir) -> [] == filelib:wildcard(filename:join(Root, Dir)) end, LibPaths)]),
247+
io:format(" +++ lists:all(fun(Dir) -> not filelib:is_dir(filename:join(Root, Dir)) end, SrcPaths):~p~n~n", [lists:all(fun(Dir) -> not filelib:is_dir(filename:join(Root, Dir)) end, SrcPaths)]),
239248
lists:any(fun(Dir) -> [] == filelib:wildcard(filename:join(Root, Dir)) end, LibPaths)
240-
andalso
249+
andalso
241250
lists:all(fun(Dir) -> not filelib:is_dir(filename:join(Root, Dir)) end, SrcPaths);
242-
_ ->
243-
true
251+
true -> true
252+
end.
244253
end.
245254

246255
prepare_plugin(AppInfo) ->

0 commit comments

Comments
 (0)