summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDave Smith <dizzyd@dizzyd.com>2010-06-09 13:45:55 -0600
committerDave Smith <dizzyd@dizzyd.com>2010-06-09 13:45:55 -0600
commit9dda9c2578877c1f437d88d5995554f957f47c08 (patch)
treea5a47e0560ae5137668e63e7afa435cc933a9915 /src
parenta86cb0b4fafbec610e724934905c4113a9614d74 (diff)
Re-adding support for plugin modules
--HG-- extra : rebase_source : 90052500da62af1d32337f2d540acb39fdf67db4
Diffstat (limited to 'src')
-rw-r--r--src/rebar_core.erl40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index 8177c43..6a825d6 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -292,8 +292,12 @@ process_dir(Dir, ParentConfig, Command, DirSet) ->
%% caused it to change
ok = file:set_cwd(Dir),
+ %% Get the list of plug-in modules from rebar.config. These modules are
+ %% processed LAST and do not participate in preprocess.
+ {ok, PluginModules} = plugin_modules(Config),
+
%% Execute the current command on this directory
- execute(Command, Modules, Config, ModuleSetFile),
+ execute(Command, Modules ++ PluginModules, Config, ModuleSetFile),
%% Mark the current directory as processed
DirSet3 = sets:add_element(Dir, DirSet2),
@@ -317,6 +321,7 @@ process_dir(Dir, ParentConfig, Command, DirSet) ->
end.
+
%%
%% Given a list of directories and a set of previously processed directories,
%% process each one we haven't seen yet
@@ -443,3 +448,36 @@ acc_modules([], _Command, _Config, _File, Acc) ->
acc_modules([Module | Rest], Command, Config, File, Acc) ->
{ok, Dirs} = Module:Command(Config, File),
acc_modules(Rest, Command, Config, File, Acc ++ Dirs).
+
+%%
+%% Return a flat list of rebar plugin modules.
+%%
+plugin_modules(Config) ->
+ Modules = lists:flatten(rebar_config:get_all(Config, rebar_plugins)),
+ plugin_modules(Config, ulist(Modules)).
+
+ulist(L) ->
+ ulist(L, []).
+
+ulist([], Acc) ->
+ lists:reverse(Acc);
+ulist([H | T], Acc) ->
+ case lists:is_member(H, Acc) of
+ true ->
+ ulist(T, Acc);
+ false ->
+ ulist(T, [H | Acc])
+ end.
+
+plugin_modules(_Config, []) ->
+ {ok, []};
+plugin_modules(_Config, Modules) ->
+ FoundModules = [M || M <- Modules, code:which(M) =/= non_existing],
+ case (Modules =:= FoundModules) of
+ true ->
+ ok;
+ false ->
+ ?WARN("Missing plugins: ~p\n", [Modules -- FoundModules]),
+ ok
+ end,
+ {ok, FoundModules}.