diff options
author | Tristan Sloughter <t@crashfast.com> | 2014-09-19 22:05:40 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2014-09-19 22:05:40 -0500 |
commit | f4f96a356fcefaa2ad388eb5469c7da901846f21 (patch) | |
tree | a701398c10006609903cc56121c44753f7c9db29 /src | |
parent | 52fcf0278d0e603f04a6b6181a61c84af1eebe5e (diff) |
install plugins to plugins/
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar3.erl | 5 | ||||
-rw-r--r-- | src/rebar_plugins.erl | 9 | ||||
-rw-r--r-- | src/rebar_prv_install_deps.erl | 36 |
3 files changed, 32 insertions, 18 deletions
diff --git a/src/rebar3.erl b/src/rebar3.erl index ec464fb..39babeb 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -140,8 +140,9 @@ run_aux(State, Args) -> %% Process each command, resetting any state between each one State2 = rebar_state:set(State1, base_dir, filename:absname(rebar_state:dir(State1))), {ok, Providers} = application:get_env(rebar, providers), - Plugins = rebar_state:get(State2, plugins, []), - State3 = rebar_state:create_logic_providers(Providers++Plugins, State2), + + rebar_plugins:install(State2), + State3 = rebar_state:create_logic_providers(Providers, State2), Task = rebar_state:get(State3, task, "help"), rebar_core:process_command(rebar_state:command_args(State3, Args), list_to_atom(Task)), ok. diff --git a/src/rebar_plugins.erl b/src/rebar_plugins.erl index 0fdbc6d..e9ab0b2 100644 --- a/src/rebar_plugins.erl +++ b/src/rebar_plugins.erl @@ -3,10 +3,17 @@ -module(rebar_plugins). --export([]). +-export([install/1]). -include("rebar.hrl"). %% =================================================================== %% Public API %% =================================================================== + +install(State) -> + BaseDir = rebar_state:get(State, base_dir, ""), + State1 = rebar_state:set(State, base_dir, "plugins"), + Plugins = rebar_state:get(State1, plugins, []), + {ok, State2} = rebar_prv_install_deps:handle_deps(State1, Plugins), + {ok, rebar_state:set(State2, base_dir, BaseDir)}. diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index d20f2b5..0752f0a 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -33,7 +33,8 @@ -include("rebar.hrl"). --export([setup_env/1]). +-export([setup_env/1, + handle_deps/2]). %% for internal use only -export([get_deps_dir/1]). @@ -65,12 +66,18 @@ init(State) -> -spec do(rebar_state:t()) -> {ok, rebar_state:t()}. do(State) -> - case rebar_state:get(State, locks, []) of - [] -> - handle_deps(State, ordsets:from_list(rebar_state:get(State, deps, []))); - Locks -> - handle_deps(State, ordsets:from_list(Locks)) - end. + ProjectApps = rebar_state:project_apps(State), + {ok, State1} = case rebar_state:get(State, locks, []) of + [] -> + handle_deps(State, ordsets:from_list(rebar_state:get(State, deps, []))); + Locks -> + handle_deps(State, ordsets:from_list(Locks)) + end, + + Source = ProjectApps ++ ordsets:to_list(rebar_state:src_deps(State1)), + {ok, Sort} = rebar_topo:sort_apps(ordsets:to_list(Source)), + {ok, rebar_state:set(State1, deps_to_build, lists:dropwhile(fun is_valid/1, Sort -- ProjectApps))}. + %% set REBAR_DEPS_DIR and ERL_LIBS environment variables setup_env(State) -> @@ -99,17 +106,12 @@ get_deps_dir(State) -> get_deps_dir(DepsDir, App) -> filename:join(DepsDir, App). -%% =================================================================== -%% Internal functions -%% =================================================================== - -spec handle_deps(rebar_state:t(), [dep()]) -> {ok, rebar_state:t()}. handle_deps(State, []) -> {ok, State}; handle_deps(State, Deps) -> %% Read in package index and dep graph {Packages, Graph} = rebar_packages:get_packages(State), - ProjectApps = rebar_state:project_apps(State), %% Split source deps form binary deps, needed to keep backwards compatibility DepsDir = get_deps_dir(State), @@ -136,14 +138,18 @@ handle_deps(State, Deps) -> end, S) end, - Source = ProjectApps ++ ordsets:to_list(rebar_state:src_deps(State2)), AllDeps = ordsets:union([ordsets:to_list(rebar_state:src_deps(State2)) ,ordsets:from_list(Solved)]), %% Sort all apps to build order State3 = rebar_state:set(State2, all_deps, AllDeps), - {ok, Sort} = rebar_topo:sort_apps(ordsets:to_list(Source)), - {ok, rebar_state:set(State3, deps_to_build, lists:dropwhile(fun is_valid/1, Sort -- ProjectApps))}. + + {ok, State3}. + + +%% =================================================================== +%% Internal functions +%% =================================================================== -spec is_valid(rebar_app_info:t()) -> boolean(). is_valid(App) -> |