summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2015-09-02 21:09:09 -0700
committerFred Hebert <mononcqc@ferd.ca>2015-09-02 21:09:09 -0700
commit3ed65f91801eb5f049a89745cd9859eaee1ef907 (patch)
tree702e77d59ecd6cb01eab02c5dc4599262985d6ea
parente385c19168aadf043adadfb3ea0bb314113d845c (diff)
parent8732b7d5bda40bd62ad8cbc1dfb34bb03edeb49e (diff)
Merge pull request #771 from tsloughter/delay_pkg_load
only load packages when needed
-rw-r--r--src/rebar3.erl2
-rw-r--r--src/rebar_packages.erl9
-rw-r--r--src/rebar_prv_packages.erl1
-rw-r--r--test/mock_pkg_resource.erl2
4 files changed, 7 insertions, 7 deletions
diff --git a/src/rebar3.erl b/src/rebar3.erl
index ab3e0eb..52b4094 100644
--- a/src/rebar3.erl
+++ b/src/rebar3.erl
@@ -105,7 +105,6 @@ run_aux(State, RawArgs) ->
{ok, Providers} = application:get_env(rebar, providers),
%% Providers can modify profiles stored in opts, so set default after initializing providers
State4 = rebar_state:create_logic_providers(Providers, State3),
- rebar_packages:packages(State4),
State5 = rebar_plugins:project_apps_install(State4),
State6 = rebar_state:default(State5, rebar_state:opts(State5)),
@@ -285,7 +284,6 @@ state_from_global_config(Config, GlobalConfigFile) ->
[] ->
GlobalConfigThrowAway;
GlobalPluginsToInstall ->
- rebar_packages:packages(GlobalConfigThrowAway),
rebar_plugins:handle_plugins(global,
GlobalPluginsToInstall,
GlobalConfigThrowAway)
diff --git a/src/rebar_packages.erl b/src/rebar_packages.erl
index e3346ae..dc111de 100644
--- a/src/rebar_packages.erl
+++ b/src/rebar_packages.erl
@@ -8,6 +8,7 @@
,package_dir/1
,registry_checksum/2
,find_highest_matching/4
+ ,verify_table/1
,format_error/1]).
-export_type([package/0]).
@@ -51,7 +52,7 @@ load_and_verify_version(State) ->
deps(Name, Vsn, State) ->
try
- verify_table(State),
+ ?MODULE:verify_table(State),
ets:lookup_element(?PACKAGE_TABLE, {ec_cnv:to_binary(Name), ec_cnv:to_binary(Vsn)}, 2)
catch
_:_ ->
@@ -82,7 +83,7 @@ package_dir(State) ->
registry_checksum({pkg, Name, Vsn}, State) ->
try
- verify_table(State),
+ ?MODULE:verify_table(State),
ets:lookup_element(?PACKAGE_TABLE, {Name, Vsn}, 3)
catch
_:_ ->
@@ -105,7 +106,7 @@ registry_checksum({pkg, Name, Vsn}, State) ->
%% `~> 2.0` | `>= 2.0.0 and < 3.0.0`
%% `~> 2.1` | `>= 2.1.0 and < 3.0.0`
find_highest_matching(Dep, Constraint, Table, State) ->
- verify_table(State),
+ ?MODULE:verify_table(State),
try ets:lookup_element(Table, Dep, 2) of
[[HeadVsn | VsnTail]] ->
{ok, handle_vsns(Constraint, HeadVsn, VsnTail)};
@@ -145,4 +146,4 @@ format_error({missing_package, Package, Version}) ->
io_lib:format("Package not found in registry: ~s-~s. Try to fix with `rebar3 update`", [Package, Version]).
verify_table(State) ->
- ets:info(?PACKAGE_TABLE, named_table) =:= true orelse ?MODULE:load_and_verify_version(State).
+ ets:info(?PACKAGE_TABLE, named_table) =:= true orelse load_and_verify_version(State).
diff --git a/src/rebar_prv_packages.erl b/src/rebar_prv_packages.erl
index 5b8ea66..998320c 100644
--- a/src/rebar_prv_packages.erl
+++ b/src/rebar_prv_packages.erl
@@ -27,6 +27,7 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
+ rebar_packages:packages(State),
print_packages(),
{ok, State}.
diff --git a/test/mock_pkg_resource.erl b/test/mock_pkg_resource.erl
index 4ed8d8e..a94fe2f 100644
--- a/test/mock_pkg_resource.erl
+++ b/test/mock_pkg_resource.erl
@@ -117,7 +117,7 @@ mock_pkg_index(Opts) ->
meck:new(rebar_packages, [passthrough, no_link]),
meck:expect(rebar_packages, packages,
fun(_State) -> to_index(Deps, Dict) end),
- meck:expect(rebar_packages, load_and_verify_version,
+ meck:expect(rebar_packages, verify_table,
fun(_State) -> to_index(Deps, Dict), true end).
%%%%%%%%%%%%%%%