summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2017-12-04 09:34:52 -0500
committerFred Hebert <mononcqc@ferd.ca>2017-12-04 09:44:39 -0500
commitfb67eb0ee95b2f03dc6c51535ab4b18ea70d315f (patch)
tree4164583568675aa18bb461df2414fc8989c683df /src
parentf81f144f38f51efd9ab2d312b1a61dc464fd4738 (diff)
Fix Plugin path handling (again!)
The path reloading of plugins had been fixed properly, but the problem is that the paths it was using to re-load only considered the current compile step, rather than the overall state of plugins. As such, the reloaded paths after plugin compilation only reloaded the *latest* plugin and not the other ones. This fix forces the addition of all built plugin paths to the code paths after a plugin compile job is run. This ensures that the path is clean for initial plugin deps (only add those that are required), and is re-made total after the fact (add all the plugins possible). This commit also includes a system tests suite that can be run optionally; the problem with this plugin mechanism was impossible to find through mocked dependencies, and a working counterexample was provided to us. The systest suite can be run against real projects without conflict to make sure no regressions are hit.
Diffstat (limited to 'src')
-rw-r--r--src/rebar_plugins.erl8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/rebar_plugins.erl b/src/rebar_plugins.erl
index 1fc01ff..57c34bc 100644
--- a/src/rebar_plugins.erl
+++ b/src/rebar_plugins.erl
@@ -96,8 +96,8 @@ handle_plugin(Profile, Plugin, State, Upgrade) ->
ToBuild = rebar_prv_install_deps:cull_compile(Sorted, []),
%% Add already built plugin deps to the code path
- CodePaths = [rebar_app_info:ebin_dir(A) || A <- Apps -- ToBuild],
- code:add_pathsa(CodePaths),
+ PreBuiltPaths = [rebar_app_info:ebin_dir(A) || A <- Apps] -- ToBuild,
+ code:add_pathsa(PreBuiltPaths),
%% Build plugin and its deps
[build_plugin(AppInfo, Apps, State2) || AppInfo <- ToBuild],
@@ -105,10 +105,12 @@ handle_plugin(Profile, Plugin, State, Upgrade) ->
%% Add newly built deps and plugin to code path
State3 = rebar_state:update_all_plugin_deps(State2, Apps),
NewCodePaths = [rebar_app_info:ebin_dir(A) || A <- ToBuild],
+ AllPluginEbins = filelib:wildcard(filename:join([rebar_dir:plugins_dir(State), "*", "ebin"])),
+ CodePaths = PreBuiltPaths++(AllPluginEbins--ToBuild),
code:add_pathsa(NewCodePaths++CodePaths),
%% Store plugin code paths so we can remove them when compiling project apps
- State4 = rebar_state:update_code_paths(State3, all_plugin_deps, CodePaths++NewCodePaths),
+ State4 = rebar_state:update_code_paths(State3, all_plugin_deps, PreBuiltPaths++NewCodePaths),
{plugin_providers(Plugin), State4}
catch