mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-24 17:29:28 +01:00
ext_mod: Fetch dependencies from hex.pm when mix is available
This doesn't work when running an OTP release build using mix, which means it doesn't work in binary installers or containers; only when using relive, or compiled with rebar3. Set the desired hex package version in the module's rebar.config For example, to fetch hex package recon 2.5.5 when mix is available, and otherwise download using git: in the file ejabberd-contrib/ejabberd_observer_cli/rebar.config set both the hex version and git details: {deps, [ {recon, "2.5.5", {git, "https://github.com/ferd/recon"}} ]}.
This commit is contained in:
parent
a935302a19
commit
101cce0c1e
@ -762,8 +762,10 @@ fetch_rebar_deps(SrcDir) ->
|
||||
{ok, CurDir} = file:get_cwd(),
|
||||
file:set_cwd(SrcDir),
|
||||
filelib:ensure_dir(filename:join("deps", ".")),
|
||||
lists:foreach(fun({_App, Cmd}) ->
|
||||
os:cmd("cd deps; "++Cmd++"; cd ..")
|
||||
lists:foreach(fun({App, Cmd}) ->
|
||||
io:format("Fetching dependency ~s: ", [App]),
|
||||
Result = os:cmd("cd deps; "++Cmd++"; cd .."),
|
||||
io:format("~s", [Result])
|
||||
end, Deps),
|
||||
file:set_cwd(CurDir)
|
||||
end.
|
||||
@ -777,6 +779,19 @@ rebar_deps(Script) ->
|
||||
_ ->
|
||||
[]
|
||||
end.
|
||||
|
||||
rebar_dep({App, Version, Git}) when Version /= ".*" ->
|
||||
AppS = atom_to_list(App),
|
||||
Help = os:cmd("mix hex.package"),
|
||||
case string:find(Help, "mix hex.package fetch") /= nomatch of
|
||||
true ->
|
||||
{App, "mix hex.package fetch "++AppS++" "++Version++" --unpack"};
|
||||
false ->
|
||||
io:format("I'll download ~p using git because I can't use Mix "
|
||||
"to fetch from hex.pm:~n~s", [AppS, help]),
|
||||
rebar_dep({App, ".*", Git})
|
||||
end;
|
||||
|
||||
rebar_dep({App, _, {git, Url}}) ->
|
||||
{App, "git clone "++Url++" "++filename:basename(App)};
|
||||
rebar_dep({App, _, {git, Url, {branch, Ref}}}) ->
|
||||
|
Loading…
Reference in New Issue
Block a user