summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inttest/depplugins/base_dir_cwd_plugin.erl7
-rw-r--r--inttest/depplugins/dep_cwd_plugin.erl7
-rw-r--r--inttest/depplugins/depplugins_rt.erl43
-rw-r--r--inttest/depplugins/rebar.config1
-rw-r--r--inttest/depplugins/rebar_testplugin.config1
-rw-r--r--inttest/depplugins/testplugin_mod.erl9
-rw-r--r--src/rebar_core.erl9
7 files changed, 59 insertions, 18 deletions
diff --git a/inttest/depplugins/base_dir_cwd_plugin.erl b/inttest/depplugins/base_dir_cwd_plugin.erl
new file mode 100644
index 0000000..4953b8b
--- /dev/null
+++ b/inttest/depplugins/base_dir_cwd_plugin.erl
@@ -0,0 +1,7 @@
+-module(base_dir_cwd_plugin).
+-export([pre_compile/2]).
+
+pre_compile(_, _) ->
+ File = "base_dir_cwd_pre.compile",
+ ok = file:write_file(File, <<"base_dir cwd pre_compile plugin">>),
+ rebar_log:log(info, "Wrote ~p/~s~n", [rebar_utils:get_cwd(), File]).
diff --git a/inttest/depplugins/dep_cwd_plugin.erl b/inttest/depplugins/dep_cwd_plugin.erl
new file mode 100644
index 0000000..fe1ceba
--- /dev/null
+++ b/inttest/depplugins/dep_cwd_plugin.erl
@@ -0,0 +1,7 @@
+-module(dep_cwd_plugin).
+-export([pre_compile/2]).
+
+pre_compile(_, _) ->
+ File = "dep_cwd_pre.compile",
+ ok = file:write_file(File, <<"dep cwd pre_compile plugin">>),
+ rebar_log:log(info, "Wrote ~p/~s~n", [rebar_utils:get_cwd(), File]).
diff --git a/inttest/depplugins/depplugins_rt.erl b/inttest/depplugins/depplugins_rt.erl
index 7b106eb..a45fa93 100644
--- a/inttest/depplugins/depplugins_rt.erl
+++ b/inttest/depplugins/depplugins_rt.erl
@@ -4,11 +4,14 @@
%%%
%%% It has three applications:
%%% <ol>
-%%% <li>fish. top-level module, has one dependency: `dependsonplugin'.</li>
-%%% <li>dependsonplugin. This depends on some pre-compile actions by the
-%%% plugin. In the test the plugin creates a file `pre.compile' in the
-%%% top-level folder of this application.</li>
-%%% <li>testplugin. This is a plugin application which creates the file.</li>
+%%% <li>fish. top-level app, has one dependency: `dependsonplugin'.
+%%% It also loads a plugin from CWD which creates
+%%% base_dir_cwd_pre.compile on pre_compile.</li>
+%%% <li>dependsonplugin, has one dependency: `testplugin' and loads
+%%% the testplugin_mod plugin.</li>
+%%% <li>testplugin. This is a plugin application which creates
+%%% plugin_pre.compile on pre_compile. It also loads a plugin from CWD
+%%% which creates dep_cwd_pre.compile on pre_compile.</li>
%%% </ol>
-module(depplugins_rt).
@@ -20,21 +23,37 @@ files() ->
[
{copy, "../../rebar", "rebar"},
{copy, "rebar.config", "rebar.config"},
+ {copy, "base_dir_cwd_plugin.erl", "base_dir_cwd_plugin.erl"},
{create, "ebin/fish.app", app(fish, [])},
- {create, "deps/dependsonplugin/ebin/dependsonplugin.app",
- app(dependsonplugin, [])},
{copy, "rebar_dependsonplugin.config",
- "deps/dependsonplugin/rebar.config"},
+ "deps/dependsonplugin/rebar.config"},
+ {create, "deps/dependsonplugin/ebin/dependsonplugin.app",
+ app(dependsonplugin, [])},
+
+ {copy, "rebar_testplugin.config", "deps/testplugin/rebar.config"},
{copy, "testplugin_mod.erl",
- "deps/testplugin/plugins/testplugin_mod.erl"},
- {create, "deps/testplugin/ebin/testplugin.app",
- app(testplugin, [])}
+ "deps/testplugin/plugins/testplugin_mod.erl"},
+ {copy, "dep_cwd_plugin.erl", "deps/testplugin/dep_cwd_plugin.erl"},
+ {create, "deps/testplugin/ebin/testplugin.app", app(testplugin, [])}
].
run(_Dir) ->
?assertMatch({ok, _}, retest_sh:run("./rebar compile", [])),
- ?assertEqual(true, filelib:is_regular("deps/dependsonplugin/pre.compile")),
+
+ ?assertEqual(true, filelib:is_regular("base_dir_cwd_pre.compile")),
+
+ ?assertEqual(true, filelib:is_regular(
+ "deps/dependsonplugin/base_dir_cwd_pre.compile")),
+ ?assertEqual(true, filelib:is_regular(
+ "deps/dependsonplugin/plugin_pre.compile")),
+
+ ?assertEqual(true, filelib:is_regular(
+ "deps/testplugin/base_dir_cwd_pre.compile")),
+ ?assertEqual(true, filelib:is_regular(
+ "deps/testplugin/dep_cwd_pre.compile")),
+ ?assertEqual(true, filelib:is_regular(
+ "deps/testplugin/plugin_pre.compile")),
ok.
%%
diff --git a/inttest/depplugins/rebar.config b/inttest/depplugins/rebar.config
index 3a2e34e..86fb037 100644
--- a/inttest/depplugins/rebar.config
+++ b/inttest/depplugins/rebar.config
@@ -1 +1,2 @@
{deps, [dependsonplugin]}.
+{plugins, [base_dir_cwd_plugin]}.
diff --git a/inttest/depplugins/rebar_testplugin.config b/inttest/depplugins/rebar_testplugin.config
new file mode 100644
index 0000000..58a1f99
--- /dev/null
+++ b/inttest/depplugins/rebar_testplugin.config
@@ -0,0 +1 @@
+{plugins, [dep_cwd_plugin]}.
diff --git a/inttest/depplugins/testplugin_mod.erl b/inttest/depplugins/testplugin_mod.erl
index 055bbc7..d829ff0 100644
--- a/inttest/depplugins/testplugin_mod.erl
+++ b/inttest/depplugins/testplugin_mod.erl
@@ -1,6 +1,7 @@
-module(testplugin_mod).
--compile(export_all).
+-export([pre_compile/2]).
-pre_compile(Config, _) ->
- ok = file:write_file("pre.compile", <<"Yadda!">>),
- rebar_log:log(info, "Wrote ~p/pre.compile~n", [rebar_utils:get_cwd()]).
+pre_compile(_, _) ->
+ File = "plugin_pre.compile",
+ ok = file:write_file(File, <<"Yadda!">>),
+ rebar_log:log(info, "Wrote ~p/~s~n", [rebar_utils:get_cwd(), File]).
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index 631cef2..4efc978 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -502,6 +502,8 @@ acc_modules([Module | Rest], Command, Config, File, Acc) ->
%%
plugin_modules(Config, PredirsAssoc) ->
Modules = lists:flatten(rebar_config:get_all(Config, plugins)),
+ ?DEBUG("Plugins requested while processing ~s: ~p~n",
+ [rebar_utils:get_cwd(), Modules]),
plugin_modules(Config, PredirsAssoc, ulist(Modules)).
ulist(L) ->
@@ -543,6 +545,7 @@ plugin_modules(Config, PredirsAssoc, FoundModules, MissingModules) ->
load_plugin_modules(Config, PredirsAssoc, Modules) ->
Cwd = rebar_utils:get_cwd(),
PluginDirs = get_all_plugin_dirs(Config, Cwd, PredirsAssoc),
+ ?DEBUG("Plugin dirs for ~s:~n~p~n", [Cwd, PluginDirs]),
%% Find relevant sources in base_dir and plugin_dir
Erls = string:join([atom_to_list(M)++"\\.erl" || M <- Modules], "|"),
@@ -558,7 +561,9 @@ load_plugin_modules(Config, PredirsAssoc, Modules) ->
{Loaded, NotLoaded}.
get_all_plugin_dirs(Config, Cwd, PredirsAssoc) ->
- get_plugin_dir(Config, Cwd) ++ get_base_plugin_dirs(Cwd, PredirsAssoc).
+ [rebar_utils:get_cwd()]
+ ++ get_plugin_dir(Config, Cwd)
+ ++ get_base_plugin_dirs(Cwd, PredirsAssoc).
get_plugin_dir(Config, Cwd) ->
case rebar_config:get_local(Config, plugin_dir, undefined) of
@@ -577,7 +582,7 @@ get_base_plugin_dirs(Cwd, PredirsAssoc) ->
[filename:join(Dir, "plugins") ||
Dir <- get_plugin_base_dirs(Cwd, PredirsAssoc)].
-%% @doc PredirsAssoc is a dictionary of plugindir -> 'parent' pairs
+%% @doc PredirsAssoc is a dictionary of plugindir -> 'parent' pairs.
%% 'parent' in this case depends on plugin; therefore we have to give
%% all plugins that Cwd ('parent' in this case) depends on.
get_plugin_base_dirs(Cwd, PredirsAssoc) ->