public ResolverResults resolve(ConfigurationInternal configuration) throws ResolveException {
    LOGGER.debug("Resolving {}", configuration);

    IvyAdapter ivyAdapter = ivyFactory.create(configuration);

    DependencyToModuleResolver dependencyResolver = ivyAdapter.getDependencyToModuleResolver();
    dependencyResolver = new ClientModuleResolver(dependencyResolver);
    dependencyResolver = new ProjectDependencyResolver(projectModuleRegistry, dependencyResolver);
    DependencyToModuleVersionIdResolver idResolver =
        new LazyDependencyToModuleResolver(
            dependencyResolver, ivyAdapter.getResolveData().getSettings().getVersionMatcher());
    idResolver =
        new VersionForcingDependencyToModuleResolver(
            idResolver, configuration.getResolutionStrategy().getDependencyResolveRule());

    ModuleConflictResolver conflictResolver;
    if (configuration.getResolutionStrategy().getConflictResolution()
        instanceof StrictConflictResolution) {
      conflictResolver = new StrictConflictResolver();
    } else {
      conflictResolver = new LatestModuleConflictResolver();
    }
    ModuleConflictResolver actualResolver = new VersionSelectionReasonResolver(conflictResolver);

    DependencyGraphBuilder builder =
        new DependencyGraphBuilder(
            moduleDescriptorConverter, resolvedArtifactFactory, idResolver, actualResolver);
    ResolutionResultBuilder resultBuilder = new ResolutionResultBuilder();
    DefaultLenientConfiguration result =
        builder.resolve(configuration, ivyAdapter.getResolveData(), resultBuilder);
    return new ResolverResults(new DefaultResolvedConfiguration(result), resultBuilder.getResult());
  }
 private void prepareTestsThatRetrieveDependencies(final ModuleDescriptor moduleDescriptor)
     throws IOException, ParseException {
   final String confName = configurationStub.getName();
   context.checking(
       new Expectations() {
         {
           allowing(configurationStub).getAll();
           will(returnValue(toSet(configurationStub, otherConfiguration)));
           allowing(configurationStub).getModule();
           will(returnValue(module));
           one(ivyFactory).create(resolutionStrategy);
           will(returnValue(ivyStub));
           one(moduleDescriptorConverter)
               .convert(
                   with(equalTo(toSet(configurationStub, otherConfiguration))),
                   with(equalTo(module)));
           will(returnValue(moduleDescriptor));
           one(ivyStub)
               .resolve(with(equal(moduleDescriptor)), with(equalResolveOptions(confName)));
           will(returnValue(resolveReportMock));
           one(ivyReportConverterStub).convertReport(resolveReportMock, configurationStub);
           will(returnValue(conversionResultStub));
         }
       });
 }
  public void resolve(
      ConfigurationInternal configuration,
      List<? extends ResolutionAwareRepository> repositories,
      GlobalDependencyResolutionRules metadataHandler,
      ResolverResults results)
      throws ResolveException {
    resolver.resolve(configuration, repositories, metadataHandler, results);
    ResolvedConfiguration resolvedConfiguration = results.getResolvedConfiguration();
    Set<Dependency> dependencies = configuration.getAllDependencies();
    CachingDependencyResolveContext resolveContext =
        new CachingDependencyResolveContext(configuration.isTransitive());
    SelfResolvingFilesProvider provider =
        new SelfResolvingFilesProvider(resolveContext, dependencies);

    results.withResolvedConfiguration(
        new FilesAggregatingResolvedConfiguration(resolvedConfiguration, provider));
  }
  public void resolve(
      ConfigurationInternal configuration,
      ResolvedConfigurationListener listener,
      ResolvedConfigurationBuilder configurationBuilder)
      throws ResolveException {
    DefaultBuildableModuleVersionResolveResult rootModule =
        new DefaultBuildableModuleVersionResolveResult();
    moduleResolver.resolve(configuration.getModule(), configuration.getAll(), rootModule);

    ResolveState resolveState =
        new ResolveState(
            rootModule,
            configuration.getName(),
            dependencyResolver,
            dependencyToConfigurationResolver,
            configurationBuilder);
    traverseGraph(resolveState);

    assembleResult(resolveState, configurationBuilder, listener);
  }
  public ResolvedConfiguration resolve(final ConfigurationInternal configuration) {
    final ResolvedConfiguration resolvedConfiguration = resolver.resolve(configuration);
    final Set<Dependency> dependencies = configuration.getAllDependencies();

    return new ResolvedConfiguration() {
      private final CachingDependencyResolveContext resolveContext =
          new CachingDependencyResolveContext(configuration.isTransitive());

      public Set<File> getFiles(Spec<? super Dependency> dependencySpec) {
        Set<File> files = new LinkedHashSet<File>();

        Set<Dependency> selectedDependencies = CollectionUtils.filter(dependencies, dependencySpec);
        for (Dependency dependency : selectedDependencies) {
          resolveContext.add(dependency);
        }
        files.addAll(resolveContext.resolve().getFiles());
        files.addAll(resolvedConfiguration.getFiles(dependencySpec));
        return files;
      }

      public Set<ResolvedArtifact> getResolvedArtifacts() {
        return resolvedConfiguration.getResolvedArtifacts();
      }

      public DependencyGraph getDependencyGraph() {
        return resolvedConfiguration.getDependencyGraph();
      }

      public Set<ResolvedDependency> getFirstLevelModuleDependencies() {
        return resolvedConfiguration.getFirstLevelModuleDependencies();
      }

      public Set<ResolvedDependency> getFirstLevelModuleDependencies(
          Spec<? super Dependency> dependencySpec) throws ResolveException {
        return resolvedConfiguration.getFirstLevelModuleDependencies(dependencySpec);
      }

      public boolean hasError() {
        return resolvedConfiguration.hasError();
      }

      public LenientConfiguration getLenientConfiguration() {
        return resolvedConfiguration.getLenientConfiguration();
      }

      public void rethrowFailure() throws GradleException {
        resolvedConfiguration.rethrowFailure();
      }
    };
  }