Skip to content

Instantly share code, notes, and snippets.

@legoscia
Created June 26, 2012 17:33
Show Gist options
  • Save legoscia/2997291 to your computer and use it in GitHub Desktop.
Save legoscia/2997291 to your computer and use it in GitHub Desktop.
Use per-user (as opposed to per-project) rebar plugins in ~/.rebar/
%% -*- erlang -*-
%% As an example, let's make the dialyzer plugin available regardless of
%% whether the project in question uses it:
{plugins, [rebar_dialyzer_plugin]}.
%% config.script uses this new variable to find it:
{plugin_home, ["/Users/magnus/.rebar"]}.
%% -*- erlang -*-
%%
%% For any plugin in the plugins directive in ~/.rebar/config that is
%% not already in the code path, add ~/.rebar/PLUGIN/ebin to the code
%% path and assert that we can find it.
PluginHome = proplists:get_value(plugin_home, CONFIG),
Plugins = proplists:get_value(plugins, CONFIG, []),
lists:foreach(
fun(Plugin) ->
code:which(Plugin) =:= non_existing andalso
code:add_path(filename:join([PluginHome, atom_to_list(Plugin), "ebin"])) andalso
(is_list(code:which(Plugin)) orelse error({plugin_not_found, Plugin}))
end, Plugins),
CONFIG.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment