anchor.diff:      UnbuiltApps = rebar_app_discover:find_unbuilt_apps([DepsDir]),
       FoundApps = rebar_app_discover:find_apps([DepsDir]),
   
  +    download_missing_deps(State, DepsDir, FoundApps, UnbuiltApps, Deps).
  +
  +update_src_deps(State, Deps) ->
  +    DepsDir = get_deps_dir(State),
  +
  +    %% Find available apps to fulfill dependencies
  +    %% Should only have to do this once, not every iteration
  +    UnbuiltApps = rebar_app_discover:find_unbuilt_apps([DepsDir]),
  +    FoundApps = rebar_app_discover:find_apps([DepsDir]),
  +
       %% Resolve deps and their dependencies
  -    Deps1 = handle_deps(Deps, UnbuiltApps++FoundApps),
  -
  -    case download_missing_deps(State, DepsDir, FoundApps, UnbuiltApps, Deps1) of
  -        {State1, []} ->
  +    Deps1 = handle_src_deps(Deps, UnbuiltApps++FoundApps),
  +    {State1, Missing} = download_missing_deps(State, DepsDir, FoundApps, UnbuiltApps, Deps1),
  +    case dict:is_empty(Missing) of
  +        true ->
               {State1, Deps1};
  -        {State1, _} ->
  -            update_deps(State1, Deps1)
  +        false ->
  +            update_src_deps(State1, Missing)
       end.
   
  -handle_deps(Deps, Found) ->
  -    NewDeps =
  -        lists:foldl(fun(X, DepsAcc) ->
  -                            C = rebar_config:consult(rebar_app_info:dir(X)),
  -                            S = rebar_state:new(rebar_state:new(), C, rebar_app_info:dir(X)),
  -                            LocalDeps = rebar_state:get(S, deps, []),
  -                            [LocalDeps | DepsAcc]
  -                    end, [], Found),
  -    NewDeps1 = lists:flatten(NewDeps),
  -
  -    %% Weed out duplicates
  -    lists:umerge(fun(A, B) ->
  -                         dep_name(A) =:= dep_name(B)
  -                 end, lists:usort(Deps), lists:usort(NewDeps1)).
  -
  -dep_name({Name, _, _}) ->
  -    Name;
  -dep_name({Name, _}) ->
  -    Name;
  -dep_name(Name) ->
  -    Name.
  -
  -
  -to_binary(X) when is_binary(X) ->
  -    X;
  -to_binary(X) when is_atom(X) ->
  -    atom_to_binary(X, utf8);
  -to_binary(X) when is_list(X) ->
  -    iolist_to_binary(X).
  +handle_src_deps(Deps, Found) ->
  +    lists:foldl(fun(X, DepsAcc) ->
  +                        C = rebar_config:consult(rebar_app_info:dir(X)),
  +                        S = rebar_state:new(rebar_state:new(), C, rebar_app_info:dir(X)),
  +                        {ParsedDeps, _Goals} = parse_deps(rebar_state:get(S, deps, [])),
  +                        dict:merge(fun(_K, V1, _V2) -> V1 end, DepsAcc, ParsedDeps)
  +                end, Deps, Found).
   
   download_missing_deps(State, DepsDir, Found, Unbuilt, Deps) ->
  -    Missing = lists:filter(fun(X) ->
  -                               not lists:any(fun(F) ->
  -                                                     to_binary(dep_name(X)) =:= to_binary(rebar_app_info:name(F))
  -                                             end, Found++Unbuilt)
  -                       end, Deps),
  -    lists:map(fun({DepName, _DepVsn, DepSource}) ->
  -                          TargetDir = get_deps_dir(DepsDir, DepName),
  -                          case filelib:is_dir(TargetDir) of
  -                              true ->
  -                                  ok;
  -                              false ->
  -                                  ?INFO("Fetching ~s ~s~n", [DepName
  -                                                            ,element(2, DepSource)]),
  -                                  rebar_fetch:download_source(TargetDir, DepSource),
  -                                  case rebar_app_discover:find_unbuilt_apps([TargetDir]) of
  -                                      [AppSrc] ->
  -                                          C = rebar_config:consult(rebar_app_info:dir(AppSrc)),
  -                                          S = rebar_state:new(rebar_state:new()
  -                                                             ,C
  -                                                             ,rebar_app_info:dir(AppSrc)),
  -                                          _AppInfo1 = rebar_prv_app_builder:build(S, AppSrc);
  -                                      [] ->
  -                                          []
  -                                  end
  -                          end
  -                  end, Missing),
  -
  -    {State, []}.
  +    Missing =
  +        dict:filter(fun(Key, _) ->
  +                            not lists:any(fun(F) ->
  +                                                  Key =:= to_binary(rebar_app_info:name(F))
  +                                          end, Found++Unbuilt)
  +                    end, Deps),
  +    dict:map(fun(_Key, #dep{name=Name, source=Source}) ->
  +                     TargetDir = get_deps_dir(DepsDir, Name),
  +                     case filelib:is_dir(TargetDir) of
  +                         true ->
  +                             ok;
  +                         false ->
  +                             ?INFO("Fetching ~s ~s~n", [Name
  +                                                       ,element(2, Source)]),
  +                             rebar_fetch:download_source(TargetDir, Source),
  +                             case rebar_app_discover:find_unbuilt_apps([TargetDir]) of
  +                                 [AppSrc] ->
  +                                     C = rebar_config:consult(rebar_app_info:dir(AppSrc)),
  +                                     S = rebar_state:new(rebar_state:new()
  +                                                        ,C
  +                                                        ,rebar_app_info:dir(AppSrc)),
  +                                     rebar_prv_app_builder:build(S, AppSrc);
  +                                 [] ->
  +                                     []
  +                             end
  +                     end
  +             end, Missing),
  +
  +    {State, Missing}.
   
   %% set REBAR_DEPS_DIR and ERL_LIBS environment variables
   setup_env(State) ->
  
positive.code:             {[], rlx_depsolver:new()}
      end.
  
  info_help(Description) ->
      io_lib:format("~s.~n"
                   "~n"
                   "Valid rebar.config options:~n"
  
negative.code: -define(PROVIDER, deps).
  -define(DEPS, [app_discovery]).
  
  -record(dep, {name :: binary(),
                vsn :: binary(),
                source :: binary()}).
  
  %% ===================================================================
  %% Public API
  %% ===================================================================
  