public RenderableUnresolvedDependencyResult(UnresolvedDependencyResult dependency) {
   this.dependency = dependency;
   ModuleVersionSelector attempted = dependency.getAttempted();
   this.actual =
       DefaultModuleVersionIdentifier.newId(
           attempted.getGroup(), attempted.getName(), attempted.getVersion());
 }
  private ModuleComponentIdentifier chooseBestMatchingDependency(
      ModuleVersionListing versions, ModuleVersionSelector requested) {
    for (Versioned candidate : sortLatestFirst(versions)) {
      // Apply version selection rules
      ModuleComponentIdentifier candidateIdentifier =
          DefaultModuleComponentIdentifier.newId(
              requested.getGroup(), requested.getName(), candidate.getVersion());
      ModuleComponentSelector requestedComponentSelector =
          DefaultModuleComponentSelector.newSelector(requested);
      VersionSelectionInternal selection =
          new DefaultVersionSelection(requestedComponentSelector, candidateIdentifier);
      versionSelectionRules.apply(selection);

      switch (selection.getState()) {
        case ACCEPTED:
          return candidateIdentifier;
        case REJECTED:
          continue;
        default:
          break;
      }

      // Invoke version matcher
      if (versionMatcher.accept(requested.getVersion(), candidate.getVersion())) {
        return candidateIdentifier;
      }
    }
    return null;
  }
 public DependencyMetaData withRequestedVersion(String requestedVersion) {
   if (requestedVersion.equals(requested.getVersion())) {
     return this;
   }
   ModuleVersionSelector newRequested =
       DefaultModuleVersionSelector.newSelector(
           requested.getGroup(), requested.getName(), requestedVersion);
   ComponentSelector newSelector = DefaultModuleComponentSelector.newSelector(newRequested);
   return copyWithTarget(newSelector, newRequested);
 }
 public UnresolvedDependencyEdge(UnresolvedDependencyResult dependency) {
   this.dependency = dependency;
   ModuleComponentSelector moduleComponentSelector = dependency.getAttempted();
   ModuleVersionSelector attempted =
       DefaultModuleVersionSelector.newSelector(
           moduleComponentSelector.getGroup(),
           moduleComponentSelector.getName(),
           moduleComponentSelector.getVersion());
   actual =
       DefaultModuleVersionIdentifier.newId(
           attempted.getGroup(), attempted.getName(), attempted.getVersion());
 }
  public void resolve(DependencyMetaData dependency, BuildableComponentResolveResult result) {
    ModuleVersionSelector requested = dependency.getRequested();
    LOGGER.debug("Attempting to resolve {} using repositories {}", requested, repositoryNames);
    ModuleComponentIdentifier moduleComponentIdentifier =
        new DefaultModuleComponentIdentifier(
            requested.getGroup(), requested.getName(), requested.getVersion());
    ModuleVersionIdentifier moduleVersionIdentifier =
        new DefaultModuleVersionIdentifier(
            requested.getGroup(), requested.getName(), requested.getVersion());

    List<Throwable> errors = new ArrayList<Throwable>();

    List<ComponentMetaDataResolveState> resolveStates =
        new ArrayList<ComponentMetaDataResolveState>();
    for (ModuleComponentRepository repository : repositories) {
      resolveStates.add(
          new ComponentMetaDataResolveState(
              dependency, moduleComponentIdentifier, repository, componentChooser));
    }

    final RepositoryChainModuleResolution latestResolved = findBestMatch(resolveStates, errors);
    if (latestResolved != null) {
      LOGGER.debug("Using {} from {}", latestResolved.module.getId(), latestResolved.repository);
      for (Throwable error : errors) {
        LOGGER.debug("Discarding resolve failure.", error);
      }

      result.resolved(metaDataFactory.transform(latestResolved));
      return;
    }
    if (!errors.isEmpty()) {
      result.failed(new ModuleVersionResolveException(moduleComponentIdentifier, errors));
    } else {
      for (ComponentMetaDataResolveState resolveState : resolveStates) {
        resolveState.applyTo(result);
      }
      result.notFound(moduleVersionIdentifier);
    }
  }
 public boolean canSelectMultipleComponents(ModuleVersionSelector selector) {
   return versionMatcher.isDynamic(selector.getVersion()) || versionSelectionRules.hasRules();
 }
 public String getDynamicConstraintVersion() {
   return requested.getVersion();
 }