rebar3WithPlugins: add ability to ignore dependencies
This commit is contained in:
parent
1ecc68dc93
commit
ae2f75ef89
@ -51,20 +51,12 @@ let
|
|||||||
|
|
||||||
inherit src;
|
inherit src;
|
||||||
|
|
||||||
|
REBAR_IGNORE_DEPS = beamDeps != [ ];
|
||||||
|
|
||||||
configurePhase = ''
|
configurePhase = ''
|
||||||
runHook preConfigure
|
runHook preConfigure
|
||||||
${lib.optionalString (checkouts != null)
|
${lib.optionalString (checkouts != null)
|
||||||
"cp --no-preserve=all -R ${checkouts}/_checkouts ."}
|
"cp --no-preserve=all -R ${checkouts}/_checkouts ."}
|
||||||
${# Prevent rebar3 from trying to manage deps
|
|
||||||
lib.optionalString (beamDeps != [ ]) ''
|
|
||||||
erl -noshell -eval '
|
|
||||||
{ok, Terms0} = file:consult("rebar.config"),
|
|
||||||
Terms = lists:keydelete(deps, 1, Terms0),
|
|
||||||
ok = file:write_file("rebar.config", [io_lib:format("~tp.~n", [T]) || T <- Terms]),
|
|
||||||
init:stop(0)
|
|
||||||
'
|
|
||||||
rm -f rebar.lock
|
|
||||||
''}
|
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -118,9 +118,11 @@ let
|
|||||||
{ok, _} = zip:extract(Archive, [{cwd, "'$out/lib'"}]),
|
{ok, _} = zip:extract(Archive, [{cwd, "'$out/lib'"}]),
|
||||||
init:stop(0)
|
init:stop(0)
|
||||||
'
|
'
|
||||||
|
cp ${./rebar_ignore_deps.erl} rebar_ignore_deps.erl
|
||||||
|
erlc -o $out/lib/rebar/ebin rebar_ignore_deps.erl
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
makeWrapper ${erlang}/bin/erl $out/bin/rebar3 \
|
makeWrapper ${erlang}/bin/erl $out/bin/rebar3 \
|
||||||
--set REBAR_GLOBAL_PLUGINS "${toString globalPluginNames}" \
|
--set REBAR_GLOBAL_PLUGINS "${toString globalPluginNames} rebar_ignore_deps" \
|
||||||
--suffix-each ERL_LIBS ":" "$out/lib ${toString pluginLibDirs}" \
|
--suffix-each ERL_LIBS ":" "$out/lib ${toString pluginLibDirs}" \
|
||||||
--add-flags "+sbtu +A1 -noshell -boot start_clean -s rebar3 main -extra"
|
--add-flags "+sbtu +A1 -noshell -boot start_clean -s rebar3 main -extra"
|
||||||
'';
|
'';
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
%% This module, when loaded as a plugin, overrides the default `install_deps`
|
||||||
|
%% provider and erases the dependencies from the rebar3 state, when
|
||||||
|
%% REBAR_IGNORE_DEPS is true.
|
||||||
|
|
||||||
|
-module(rebar_ignore_deps).
|
||||||
|
|
||||||
|
-export([init/1, do/1, format_error/1]).
|
||||||
|
|
||||||
|
init(State0) ->
|
||||||
|
case os:getenv("REBAR_IGNORE_DEPS", "") of
|
||||||
|
"" ->
|
||||||
|
{ok, State0};
|
||||||
|
_ ->
|
||||||
|
do_init(State0)
|
||||||
|
end.
|
||||||
|
|
||||||
|
do_init(State0) ->
|
||||||
|
State1 = rebar_state:allow_provider_overrides(State0, true),
|
||||||
|
Provider = providers:create(
|
||||||
|
[
|
||||||
|
{name, install_deps}, %% override the default install_deps provider
|
||||||
|
{module, ?MODULE},
|
||||||
|
{bare, false},
|
||||||
|
{deps, [app_discovery]},
|
||||||
|
{example, undefined},
|
||||||
|
{opts, []},
|
||||||
|
{short_desc, ""},
|
||||||
|
{desc, ""}
|
||||||
|
]),
|
||||||
|
State2 = rebar_state:add_provider(State1, Provider),
|
||||||
|
{ok, rebar_state:allow_provider_overrides(State2, false)}.
|
||||||
|
|
||||||
|
do(State0) ->
|
||||||
|
io:format("Ignoring deps...~n"),
|
||||||
|
Profiles = rebar_state:current_profiles(State0),
|
||||||
|
State = lists:foldl(fun(P, Acc0) ->
|
||||||
|
Acc = rebar_state:set(Acc0, {deps, P}, []),
|
||||||
|
rebar_state:set(Acc, {parsed_deps, P}, [])
|
||||||
|
end, State0, Profiles),
|
||||||
|
{ok, State}.
|
||||||
|
|
||||||
|
format_error(Reason) ->
|
||||||
|
io_lib:format("~p", [Reason]).
|
Loading…
Reference in New Issue
Block a user