summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar3.erl3
-rw-r--r--src/rebar_pkg_resource.erl2
-rw-r--r--src/rebar_plugins.erl18
-rw-r--r--src/rebar_prv_common_test.erl25
-rw-r--r--src/rebar_prv_dialyzer.erl23
-rw-r--r--src/rebar_prv_update.erl2
-rw-r--r--src/rebar_utils.erl7
7 files changed, 63 insertions, 17 deletions
diff --git a/src/rebar3.erl b/src/rebar3.erl
index 84d7c3e..879378e 100644
--- a/src/rebar3.erl
+++ b/src/rebar3.erl
@@ -105,6 +105,9 @@ run_aux(State, RawArgs) ->
rebar_state:apply_profiles(State, [list_to_atom(Profile)])
end,
+ rebar_utils:check_min_otp_version(rebar_state:get(State1, minimum_otp_vsn, undefined)),
+ rebar_utils:check_blacklisted_otp_versions(rebar_state:get(State1, blacklisted_otp_vsns, undefined)),
+
State2 = case os:getenv("HEX_CDN") of
false ->
State1;
diff --git a/src/rebar_pkg_resource.erl b/src/rebar_pkg_resource.erl
index 33687e4..ec7e09d 100644
--- a/src/rebar_pkg_resource.erl
+++ b/src/rebar_pkg_resource.erl
@@ -104,7 +104,7 @@ make_vsn(_) ->
{error, "Replacing version of type pkg not supported."}.
request(Url, ETag) ->
- case httpc:request(get, {Url, [{"if-none-match", ETag} || ETag =/= false]},
+ case httpc:request(get, {Url, [{"if-none-match", ETag} || ETag =/= false]++[{"User-Agent", rebar_utils:user_agent()}]},
[{ssl, ssl_opts(Url)}, {relaxed, true}],
[{body_format, binary}],
rebar) of
diff --git a/src/rebar_plugins.erl b/src/rebar_plugins.erl
index b4cc3ec..3c33498 100644
--- a/src/rebar_plugins.erl
+++ b/src/rebar_plugins.erl
@@ -42,10 +42,20 @@ project_apps_install(State) ->
-spec install(rebar_state:t(), rebar_app_info:t()) -> rebar_state:t().
install(State, AppInfo) ->
Profiles = rebar_state:current_profiles(State),
- lists:foldl(fun(Profile, StateAcc) ->
- Plugins = rebar_app_info:get(AppInfo, {plugins, Profile}, []),
- handle_plugins(Profile, Plugins, StateAcc)
- end, State, Profiles).
+
+ %% don't lose the overrides of the dep we are processing plugins for
+ Overrides = rebar_app_info:get(AppInfo, overrides, []),
+ StateOverrides = rebar_state:get(State, overrides, []),
+ AllOverrides = Overrides ++ StateOverrides,
+ State1 = rebar_state:set(State, overrides, AllOverrides),
+
+ State2 = lists:foldl(fun(Profile, StateAcc) ->
+ Plugins = rebar_app_info:get(AppInfo, {plugins, Profile}, []),
+ handle_plugins(Profile, Plugins, StateAcc)
+ end, State1, Profiles),
+
+ %% Reset the overrides after processing the dep
+ rebar_state:set(State2, overrides, StateOverrides).
handle_plugins(Profile, Plugins, State) ->
handle_plugins(Profile, Plugins, State, false).
diff --git a/src/rebar_prv_common_test.erl b/src/rebar_prv_common_test.erl
index 1136e08..4be50d8 100644
--- a/src/rebar_prv_common_test.erl
+++ b/src/rebar_prv_common_test.erl
@@ -281,7 +281,8 @@ inject_ct_state(State, [App|Rest], Acc) ->
inject_ct_state(State, [], Acc) ->
case inject(rebar_state:opts(State), State) of
{error, _} = Error -> Error;
- NewOpts -> {ok, {rebar_state:opts(State, NewOpts), lists:reverse(Acc)}}
+ NewOpts ->
+ {ok, {rebar_state:opts(State, NewOpts), lists:reverse(Acc)}}
end.
opts(Opts, Key, Default) ->
@@ -380,12 +381,10 @@ maybe_inject_test_dir(State, AppAcc, [App|Rest], Dir) ->
%% suite exists in but if the suite is in the app root directory
%% the current compiler tries to compile all subdirs including priv
%% instead copy only files ending in `.erl' and directories
- %% ending in `_SUITE_data' into the `_build/PROFILE/extras' dir
- {ok, RelAppDir} = rebar_file_utils:path_from_ancestor(rebar_app_info:dir(App), rebar_state:dir(State)),
- ExtrasDir = filename:join([rebar_dir:base_dir(State), "extras", RelAppDir]),
- ok = copy_bare_suites(Dir, ExtrasDir),
- Opts = inject_test_dir(rebar_state:opts(State), ExtrasDir),
- {rebar_state:opts(State, Opts), AppAcc};
+ %% ending in `_SUITE_data' into the `_build/PROFILE/lib/APP' dir
+ ok = copy_bare_suites(Dir, rebar_app_info:out_dir(App)),
+ Opts = inject_test_dir(rebar_state:opts(State), rebar_app_info:out_dir(App)),
+ {rebar_state:opts(State, Opts), AppAcc ++ [App]};
{ok, Path} ->
Opts = inject_test_dir(rebar_app_info:opts(App), Path),
{State, AppAcc ++ [rebar_app_info:opts(App, Opts)] ++ Rest};
@@ -449,15 +448,23 @@ translate_suites(_State, [], Acc) -> lists:reverse(Acc);
translate_suites(State, [{suite, Suite}|Rest], Acc) when is_integer(hd(Suite)) ->
%% single suite
Apps = rebar_state:project_apps(State),
- translate_suites(State, Rest, [{suite, translate(State, Apps, Suite)}|Acc]);
+ translate_suites(State, Rest, [{suite, translate_suite(State, Apps, Suite)}|Acc]);
translate_suites(State, [{suite, Suites}|Rest], Acc) ->
%% multiple suites
Apps = rebar_state:project_apps(State),
- NewSuites = {suite, lists:map(fun(Suite) -> translate(State, Apps, Suite) end, Suites)},
+ NewSuites = {suite, lists:map(fun(Suite) -> translate_suite(State, Apps, Suite) end, Suites)},
translate_suites(State, Rest, [NewSuites|Acc]);
translate_suites(State, [Test|Rest], Acc) ->
translate_suites(State, Rest, [Test|Acc]).
+translate_suite(State, Apps, Suite) ->
+ Dirname = filename:dirname(Suite),
+ Basename = filename:basename(Suite),
+ case Dirname of
+ "." -> Suite;
+ _ -> filename:join([translate(State, Apps, Dirname), Basename])
+ end.
+
translate(State, [App|Rest], Path) ->
case rebar_file_utils:path_from_ancestor(Path, rebar_app_info:dir(App)) of
{ok, P} -> filename:join([rebar_app_info:out_dir(App), P]);
diff --git a/src/rebar_prv_dialyzer.erl b/src/rebar_prv_dialyzer.erl
index 2e5728a..834eb98 100644
--- a/src/rebar_prv_dialyzer.erl
+++ b/src/rebar_prv_dialyzer.erl
@@ -397,7 +397,7 @@ run_dialyzer(State, Opts, Output) ->
case proplists:get_bool(get_warnings, Opts) of
true ->
WarningsList = get_config(State, warnings, []),
- Opts2 = [{warnings, WarningsList},
+ Opts2 = [{warnings, legacy_warnings(WarningsList)},
{check_plt, false} |
Opts],
?DEBUG("Running dialyzer with options: ~p~n", [Opts2]),
@@ -412,6 +412,14 @@ run_dialyzer(State, Opts, Output) ->
{0, State}
end.
+legacy_warnings(Warnings) ->
+ case dialyzer_version() of
+ TupleVsn when TupleVsn < {2, 8, 0} ->
+ [Warning || Warning <- Warnings, Warning =/= unknown];
+ _ ->
+ Warnings
+ end.
+
format_warnings(Output, Warnings) ->
Warnings1 = rebar_dialyzer_format:format_warnings(Warnings),
console_warnings(Warnings1),
@@ -475,3 +483,16 @@ collect_nested_dependent_apps(App, Seen) ->
end
end
end.
+
+dialyzer_version() ->
+ _ = application:load(dialyzer),
+ {ok, Vsn} = application:get_key(dialyzer, vsn),
+ case string:tokens(Vsn, ".") of
+ [Major, Minor] ->
+ version_tuple(Major, Minor, "0");
+ [Major, Minor, Patch | _] ->
+ version_tuple(Major, Minor, Patch)
+ end.
+
+version_tuple(Major, Minor, Patch) ->
+ {list_to_integer(Major), list_to_integer(Minor), list_to_integer(Patch)}.
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
index 1cdf6af..0e3b9a0 100644
--- a/src/rebar_prv_update.erl
+++ b/src/rebar_prv_update.erl
@@ -48,7 +48,7 @@ do(State) ->
case rebar_utils:url_append_path(CDN, ?REMOTE_REGISTRY_FILE) of
{ok, Url} ->
?DEBUG("Fetching registry from ~p", [Url]),
- case httpc:request(get, {Url, []},
+ case httpc:request(get, {Url, [{"User-Agent", rebar_utils:user_agent()}]},
[], [{stream, TmpFile}, {sync, true}],
rebar) of
{ok, saved_to_file} ->
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 07bf789..56a3940 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -68,7 +68,8 @@
check_min_otp_version/1,
check_blacklisted_otp_versions/1,
info_useless/2,
- list_dir/1]).
+ list_dir/1,
+ user_agent/0]).
%% for internal use only
-export([otp_release/0]).
@@ -407,6 +408,10 @@ abort_if_blacklisted(BlacklistedRegex, OtpRelease) ->
[OtpRelease, BlacklistedRegex])
end.
+user_agent() ->
+ {ok, Vsn} = application:get_key(rebar, vsn),
+ ?FMT("Rebar/~s (OTP/~s)", [Vsn, otp_release()]).
+
%% ====================================================================
%% Internal functions
%% ====================================================================