anchor.diff:           find_apps/2,
            find_app/2]).
   
  +-include("rebar.hrl").
   -include_lib("providers/include/providers.hrl").
   
   do(State, LibDirs) ->
  
positive.code:                     end;
                  all ->
                      {true, AppInfo2}
              end;
          [] ->
              case AppSrcFile of
                  [File] ->
                      case Validate of
                          V when V =:= invalid ; V =:= all ->
                              AppInfo = create_app_info(AppDir, File),
                              case AppInfo of
                                {error, Reason} ->
                                    throw({error, {invalid_app_file, File, Reason}});
                                _ ->
                                    {true, rebar_app_info:app_file_src(AppInfo, File)}
                              end;
                          valid ->
                              false
                      end;
                  [] ->
                      false;
                  Other when is_list(Other) ->
                      throw({error, {multiple_app_files, Other}})
              end;
          Other when is_list(Other) ->
              throw({error, {multiple_app_files, Other}})
      end.
  
  app_dir(AppFile) ->
      filename:join(rebar_utils:droplast(filename:split(filename:dirname(AppFile)))).
  
  -spec create_app_info(file:name(), file:name()) -> rebar_app_info:t() | {error, term()}.
  create_app_info(AppDir, AppFile) ->
      [{application, AppName, AppDetails}] = rebar_file_utils:try_consult(AppFile),
      AppVsn = proplists:get_value(vsn, AppDetails),
      Applications = proplists:get_value(applications, AppDetails, []),
      IncludedApplications = proplists:get_value(included_applications, AppDetails, []),
      {ok, AppInfo} = rebar_app_info:new(AppName, AppVsn, AppDir, []),
      AppInfo1 = rebar_app_info:applications(
                   rebar_app_info:app_details(AppInfo, AppDetails),
                   IncludedApplications++Applications),
      Valid = case rebar_app_utils:validate_application_info(AppInfo1) of
                  true ->
                      true;
                  _ ->
                      false
              end,
      rebar_app_info:dir(rebar_app_info:valid(AppInfo1, Valid), AppDir).
  
  dedup([]) -> [];
  dedup([A]) -> [A];
  dedup([H,H|T]) -> dedup([H|T]);
  dedup([H|T]) -> [H|dedup(T)].
  
negative.code: find_app(AppDir, Validate) ->
      AppFile = filelib:wildcard(filename:join([AppDir, "ebin", "*.app"])),
      AppSrcFile = filelib:wildcard(filename:join([AppDir, "src", "*.app.src"])),
      try_handle_app_file(AppFile, AppDir, AppSrcFile, Validate).
  
  app_dir(AppFile) ->
      filename:join(rebar_utils:droplast(filename:split(filename:dirname(AppFile)))).
  
  -spec create_app_info(file:name(), file:name()) -> rebar_app_info:t() | {error, term()}.
  create_app_info(AppDir, AppFile) ->
      [{application, AppName, AppDetails}] = rebar_file_utils:try_consult(AppFile),
      AppVsn = proplists:get_value(vsn, AppDetails),
      Applications = proplists:get_value(applications, AppDetails, []),
      IncludedApplications = proplists:get_value(included_applications, AppDetails, []),
      {ok, AppInfo} = rebar_app_info:new(AppName, AppVsn, AppDir, []),
      AppInfo1 = rebar_app_info:applications(
                   rebar_app_info:app_details(AppInfo, AppDetails),
                   IncludedApplications++Applications),
      Valid = case rebar_app_utils:validate_application_info(AppInfo1) of
                  true ->
                      true;
                  _ ->
                      false
              end,
      rebar_app_info:dir(rebar_app_info:valid(AppInfo1, Valid), AppDir).
  
  dedup([]) -> [];
  dedup([A]) -> [A];
  dedup([H,H|T]) -> dedup([H|T]);
  dedup([H|T]) -> [H|dedup(T)].
  
  try_handle_app_file([], AppDir, AppSrcFile, Validate) ->
      try_handle_app_src_file([], AppDir, AppSrcFile, Validate);
  try_handle_app_file([File], AppDir, AppSrcFile, Validate) ->
      try create_app_info(AppDir, File) of
          AppInfo ->
              AppInfo1 = rebar_app_info:app_file(AppInfo, File),
              AppInfo2 = case AppSrcFile of
                             [F] ->
  