Commits

dizzyd committed e7f8d68

Re-adding support for plugin modules

Comments (0)

Files changed (1)

src/rebar_core.erl

             %% 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),
     end.
 
 
+
 %%
 %% Given a list of directories and a set of previously processed directories,
 %% process each one we haven't seen yet
 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}.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.