diff options
author | Adam Schepis <adam.schepis@gmail.com> | 2012-02-10 09:55:36 -0500 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2012-03-31 19:21:25 +0200 |
commit | 03a026f38fde8eb2b39447eb25aa219d017989fd (patch) | |
tree | 2a8c25c365503c549916620eb371c4a968d29907 /src | |
parent | 3469039201511d62d6d545ae8b54fae94dfd5e92 (diff) |
Add support for alternate dependency urls
This change adds the ability to use alternate urls for downloading
dependencies. To make use of alternate urls run:
rebar get-deps alt_urls=true
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_deps.erl | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/rebar_deps.erl b/src/rebar_deps.erl index 2085cf2..c6e3ff6 100644 --- a/src/rebar_deps.erl +++ b/src/rebar_deps.erl @@ -223,15 +223,30 @@ find_deps(Mode, [App | Rest], Acc) when is_atom(App) -> find_deps(Mode, [{App, VsnRegex} | Rest], Acc) when is_atom(App) -> find_deps(Mode, [{App, VsnRegex, undefined} | Rest], Acc); find_deps(Mode, [{App, VsnRegex, Source} | Rest], Acc) -> + find_deps(Mode, [{App, VsnRegex, Source, []} | Rest], Acc); +find_deps(Mode, [{App, VsnRegex, Source, Opts} | Rest], Acc) -> Dep = #dep { app = App, vsn_regex = VsnRegex, - source = Source }, + source = get_source(Source, Opts) }, {Availability, FoundDir} = find_dep(Dep), find_deps(Mode, Rest, acc_deps(Mode, Availability, Dep, FoundDir, Acc)); find_deps(_Mode, [Other | _Rest], _Acc) -> ?ABORT("Invalid dependency specification ~p in ~s\n", [Other, rebar_utils:get_cwd()]). +get_source(undefined, _Opts) -> + undefined; +get_source(Source, Opts) -> + setelement(2, Source, dep_url(element(2, Source), Opts)). + +dep_url(Url, Opts) -> + case rebar_config:get_global(alt_urls, "false") of + "true" -> + proplists:get_value(alt_url, Opts, Url); + "false" -> + Url + end. + find_dep(Dep) -> %% Find a dep based on its source, %% e.g. {git, "https://github.com/mochi/mochiweb.git", "HEAD"} |