From b93bb358194a0aabc1b4c6f2ce80c0df81d79b6a Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Sun, 22 Dec 2019 03:00:22 +0300 Subject: [PATCH] Only suppress deprecation warnings on OTP 23 For OTP 19 and earlier compatibility. --- src/r3_hex_api.erl | 6 +++++- src/rebar_git_resource.erl | 8 ++++++-- src/rebar_utils.erl | 8 ++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/r3_hex_api.erl b/src/r3_hex_api.erl index 66a08858..a19472f1 100644 --- a/src/r3_hex_api.erl +++ b/src/r3_hex_api.erl @@ -28,7 +28,11 @@ put(Config, Path, Body) -> delete(Config, Path) -> request(Config, delete, Path, undefined). --compile({nowarn_deprecated_function, [{http_uri, encode, 1}]}). +-ifdef (OTP_RELEASE). + -if(?OTP_RELEASE >= 23). + -compile({nowarn_deprecated_function, [{http_uri, encode, 1}]}). + -endif. +-endif. %% @private encode_query_string(List) -> diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl index b2769746..45bc0432 100644 --- a/src/rebar_git_resource.erl +++ b/src/rebar_git_resource.erl @@ -100,8 +100,12 @@ compare_url(Dir, Url) -> ?DEBUG("Comparing git url ~p with ~p", [ParsedUrl, ParsedCurrentUrl]), ParsedCurrentUrl =:= ParsedUrl. --compile({nowarn_deprecated_function, [{http_uri, parse, 2}, - {http_uri, scheme_defaults, 0}]}). +-ifdef (OTP_RELEASE). + -if(?OTP_RELEASE >= 23). + -compile({nowarn_deprecated_function, [{http_uri, parse, 2}, + {http_uri, scheme_defaults, 0}]}). + -endif. +-endif. parse_git_url(Url) -> %% Checks for standard scp style git remote diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index af52f428..b9a8e64c 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -908,8 +908,12 @@ get_http_vars(Scheme) -> Config = rebar_config:consult_file(GlobalConfigFile), proplists:get_value(Scheme, Config, OS). --compile({nowarn_deprecated_function, [{http_uri, parse, 1}, - {http_uri, decode, 1}]}). +-ifdef (OTP_RELEASE). + -if(?OTP_RELEASE >= 23). + -compile({nowarn_deprecated_function, [{http_uri, parse, 1}, + {http_uri, decode, 1}]}). + -endif. +-endif. set_httpc_options() -> set_httpc_options(https_proxy, get_http_vars(https_proxy)),