diff options
author | Jesse Gumm <gumm@sigma-star.com> | 2016-03-20 09:18:06 -0500 |
---|---|---|
committer | Jesse Gumm <gumm@sigma-star.com> | 2016-03-20 10:58:20 -0500 |
commit | 3b345046bde490641866e6098d9145c360b04205 (patch) | |
tree | 8eb49a3153980e6f9de9f06c1756f26578d9d023 | |
parent | ef73556df92dd3b31daaf1cc6d97fb220dfcaa0c (diff) | |
download | rebar-3b345046bde490641866e6098d9145c360b04205.tar.gz |
Support rebar3-style deps
Example: {git, {appname, "git://something/something", {branch, master}}}
^
|
|---- Notice the lack of a version Regex
-rw-r--r-- | inttest/rebar3_deps1/a.erl | 8 | ||||
-rw-r--r-- | inttest/rebar3_deps1/a.rebar.config | 1 | ||||
-rw-r--r-- | inttest/rebar3_deps1/b.hrl | 1 | ||||
-rw-r--r-- | inttest/rebar3_deps1/rebar3_deps1_rt.erl | 59 | ||||
-rw-r--r-- | src/rebar_deps.erl | 8 |
5 files changed, 77 insertions, 0 deletions
diff --git a/inttest/rebar3_deps1/a.erl b/inttest/rebar3_deps1/a.erl new file mode 100644 index 0000000..835522a --- /dev/null +++ b/inttest/rebar3_deps1/a.erl @@ -0,0 +1,8 @@ +-module(a). + +-compile(export_all). + +-include_lib("b/include/b.hrl"). + +hello() -> + io:format("~s\n", [?HELLO]). diff --git a/inttest/rebar3_deps1/a.rebar.config b/inttest/rebar3_deps1/a.rebar.config new file mode 100644 index 0000000..6b20717 --- /dev/null +++ b/inttest/rebar3_deps1/a.rebar.config @@ -0,0 +1 @@ +{deps, [{b, {git, "../repo/b"}}]}. diff --git a/inttest/rebar3_deps1/b.hrl b/inttest/rebar3_deps1/b.hrl new file mode 100644 index 0000000..25dfeda --- /dev/null +++ b/inttest/rebar3_deps1/b.hrl @@ -0,0 +1 @@ +-define(HELLO, "Hi From B"). diff --git a/inttest/rebar3_deps1/rebar3_deps1_rt.erl b/inttest/rebar3_deps1/rebar3_deps1_rt.erl new file mode 100644 index 0000000..36f94e3 --- /dev/null +++ b/inttest/rebar3_deps1/rebar3_deps1_rt.erl @@ -0,0 +1,59 @@ +%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% ex: ts=4 sw=4 et +-module(rebar3_deps1_rt). + +-compile(export_all). + +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + +%% Test deps with rebar3-type dependencies (that is, dependencies without Regexes) +%% Example: {git, {appname, "git://something/something", {branch, master}}} +files() -> + [ + %% A application + {create, "ebin/a.app", app(a, [a])}, + {copy, "a.rebar.config", "rebar.config"}, + {copy, "a.erl", "src/a.erl"}, + + %% B application + {create, "repo/b/ebin/b.app", app(b, [])}, + {copy, "b.hrl", "repo/b/include/b.hrl"} + + ] ++ inttest_utils:rebar_setup(). + +apply_cmds([], _Params) -> + ok; +apply_cmds([Cmd | Rest], Params) -> + io:format("Running: ~s (~p)\n", [Cmd, Params]), + {ok, _} = retest_sh:run(Cmd, Params), + apply_cmds(Rest, Params). + +run(_Dir) -> + %% Initialize the dep app as git repos so that dependencies pull + %% properly + GitCmds = ["git init", + "git add -A", + "git config user.email 'tdeps@example.com'", + "git config user.name 'tdeps'", + "git commit -a -m \"Initial Commit\""], + apply_cmds(GitCmds, [{dir, "repo/b"}]), + + {ok, _} = retest_sh:run("./rebar get-deps", []), + {ok, _} = retest_sh:run("./rebar compile", []), + + true = filelib:is_regular("ebin/a.beam"), + ok. + +%% +%% Generate the contents of a simple .app file +%% +app(Name, Modules) -> + App = {application, Name, + [{description, atom_to_list(Name)}, + {vsn, "1"}, + {modules, Modules}, + {registered, []}, + {applications, [kernel, stdlib]}]}, + io_lib:format("~p.\n", [App]). diff --git a/src/rebar_deps.erl b/src/rebar_deps.erl index 995ce97..def703b 100644 --- a/src/rebar_deps.erl +++ b/src/rebar_deps.erl @@ -268,10 +268,16 @@ info_help(Description) -> {rebar, "1.0.*"}, {rebar, ".*", {git, "git://github.com/rebar/rebar.git"}}, + {rebar, + {git, "git://github.com/rebar/rebar.git"}}, {rebar, ".*", {git, "git://github.com/rebar/rebar.git", "Rev"}}, + {rebar, + {git, "git://github.com/rebar/rebar.git", "Rev"}}, {rebar, "1.0.*", {git, "git://github.com/rebar/rebar.git", {branch, "master"}}}, + {rebar, + {git, "git://github.com/rebar/rebar.git", {branch, "master"}}}, {rebar, "1.0.0", {git, "git://github.com/rebar/rebar.git", {tag, "1.0.0"}}}, {rebar, "", @@ -371,6 +377,8 @@ find_deps(Config, read, [], Deps) -> {Config, lists:reverse(Deps)}; find_deps(Config, Mode, [App | Rest], Acc) when is_atom(App) -> find_deps(Config, Mode, [{App, ".*", undefined} | Rest], Acc); +find_deps(Config, Mode, [{App, Source} | Rest], Acc) when is_tuple(Source) -> + find_deps(Config, Mode, [{App, ".*", Source} | Rest], Acc); find_deps(Config, Mode, [{App, VsnRegex} | Rest], Acc) when is_atom(App) -> find_deps(Config, Mode, [{App, VsnRegex, undefined} | Rest], Acc); find_deps(Config, Mode, [{App, VsnRegex, Source} | Rest], Acc) -> |