diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_app_utils.erl | 35 | ||||
-rw-r--r-- | src/rebar_config.erl | 9 | ||||
-rw-r--r-- | src/rebar_prv_install_deps.erl | 4 |
3 files changed, 42 insertions, 6 deletions
diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index 7239fe7..693ad1c 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -117,6 +117,33 @@ parse_dep(Dep, Parent, DepsDir, State, Locks, Level) -> end end. +parse_dep(Parent, {Name, Vsn, {pkg, PkgName}}, DepsDir, IsLock, State) -> + %% Versioned Package dependency with different package name from app name + CheckoutsDir = ec_cnv:to_list(rebar_dir:checkouts_dir(State, PkgName)), + case rebar_app_info:discover(CheckoutsDir) of + {ok, _App} -> + dep_to_app(root, DepsDir, Name, [], [], IsLock, State); + not_found -> + {PkgName1, PkgVsn} = parse_goal(ec_cnv:to_binary(PkgName) + ,ec_cnv:to_binary(Vsn)), + %% Verify package actually exists. This will throw a missing_package exception + rebar_packages:deps(PkgName1, PkgVsn, State), + Source = {pkg, PkgName1, PkgVsn}, + rebar_app_info:resource_type(dep_to_app(Parent, DepsDir, Name, PkgVsn, Source, IsLock, State), pkg) + end; +parse_dep(Parent, {Name, {pkg, PkgName}}, DepsDir, IsLock, State) -> + %% Package dependency with different package name from app name + {PkgName1, PkgVsn} = get_package(ec_cnv:to_binary(PkgName), State), + CheckoutsDir = ec_cnv:to_list(rebar_dir:checkouts_dir(State, PkgName1)), + case rebar_app_info:discover(CheckoutsDir) of + {ok, _App} -> + dep_to_app(root, DepsDir, Name, [], [], IsLock, State); + not_found -> + %% Verify package actually exists. This will throw a missing_package exception + rebar_packages:deps(PkgName1, PkgVsn, State), + Source = {pkg, PkgName1, PkgVsn}, + rebar_app_info:resource_type(dep_to_app(Parent, DepsDir, Name, PkgVsn, Source, IsLock, State), pkg) + end; parse_dep(Parent, {Name, Vsn}, DepsDir, IsLock, State) when is_list(Vsn); is_binary(Vsn) -> %% Versioned Package dependency CheckoutsDir = ec_cnv:to_list(rebar_dir:checkouts_dir(State, Name)), @@ -151,15 +178,15 @@ parse_dep(Parent, {Name, _Vsn, Source}, DepsDir, IsLock, State) when is_tuple(So parse_dep(Parent, {Name, _Vsn, Source, Opts}, DepsDir, IsLock, State) when is_tuple(Source) -> ?WARN("Dependency option list ~p in ~p is not supported and will be ignored", [Opts, Name]), dep_to_app(Parent, DepsDir, Name, [], Source, IsLock, State); -parse_dep(Parent, {_Name, {pkg, Name, Vsn}, Level}, DepsDir, IsLock, State) when is_integer(Level) -> - CheckoutsDir = ec_cnv:to_list(rebar_dir:checkouts_dir(State, Name)), +parse_dep(Parent, {Name, {pkg, PkgName, Vsn}, Level}, DepsDir, IsLock, State) when is_integer(Level) -> + CheckoutsDir = ec_cnv:to_list(rebar_dir:checkouts_dir(State, PkgName)), case rebar_app_info:discover(CheckoutsDir) of {ok, _App} -> dep_to_app(root, DepsDir, Name, [], [], IsLock, State); not_found -> %% Verify package actually exists. This will throw a missing_package exception - rebar_packages:deps(Name, Vsn, State), - Source = {pkg, Name, Vsn}, + rebar_packages:deps(PkgName, Vsn, State), + Source = {pkg, PkgName, Vsn}, rebar_app_info:resource_type(dep_to_app(Parent, DepsDir, Name, Vsn, Source, IsLock, State), pkg) end; parse_dep(Parent, {Name, Source, Level}, DepsDir, IsLock, State) when is_tuple(Source) diff --git a/src/rebar_config.erl b/src/rebar_config.erl index 554b399..b9b8b2e 100644 --- a/src/rebar_config.erl +++ b/src/rebar_config.erl @@ -128,11 +128,20 @@ find_newly_added(ConfigDeps, LockedDeps) -> check_newly_added({_, _}=Dep, LockedDeps) -> check_newly_added_(Dep, LockedDeps); +check_newly_added({_, _, {pkg, _}}=Dep, LockedDeps) -> + check_newly_added_(Dep, LockedDeps); check_newly_added({Name, _, Source}, LockedDeps) -> check_newly_added_({Name, Source}, LockedDeps); check_newly_added(Dep, LockedDeps) -> check_newly_added_(Dep, LockedDeps). +check_newly_added_({Name, Vsn, Source}, LockedDeps) -> + case check_newly_added_(Name, LockedDeps) of + {true, Name1} -> + {true, {Name1, Vsn, Source}}; + false -> + false + end; check_newly_added_({Name, Source}, LockedDeps) -> case check_newly_added_(Name, LockedDeps) of {true, Name1} -> diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 49116fc..4dfe1e2 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -251,7 +251,6 @@ update_unseen_dep(AppInfo, Profile, Level, Deps, Apps, State, Upgrade, Seen, Loc handle_dep(State, Profile, DepsDir, AppInfo, Locks, Level) -> Profiles = rebar_state:current_profiles(State), Name = rebar_app_info:name(AppInfo), - Vsn = rebar_app_info:original_vsn(AppInfo), %% Deps may be under a sub project app, find it and use its state if so S = rebar_app_info:state(AppInfo), @@ -273,7 +272,8 @@ handle_dep(State, Profile, DepsDir, AppInfo, Locks, Level) -> %% Upgrade lock level to be the level the dep will have in this dep tree case rebar_app_info:resource_type(AppInfo1) of pkg -> - NewDeps = rebar_packages:deps(Name, Vsn, S5), + {pkg, PkgName, PkgVsn} = rebar_app_info:source(AppInfo1), + NewDeps = rebar_packages:deps(PkgName, PkgVsn, S5), NewDeps1 = rebar_app_utils:parse_deps(Name, DepsDir, NewDeps, S5, Locks, Level+1), {rebar_app_info:deps(AppInfo1, NewDeps), NewDeps1, State}; _ -> |