Search in sources :

Example 26 with ModuleVersionResolveException

use of org.gradle.internal.resolve.ModuleVersionResolveException in project gradle by gradle.

the class DefaultResolutionResultBuilder method addExtraFailures.

public void addExtraFailures(Long rootId, Set<UnresolvedDependency> extraFailures) {
    DefaultResolvedComponentResult root = modules.get(rootId);
    for (UnresolvedDependency failure : extraFailures) {
        ModuleVersionSelector failureSelector = failure.getSelector();
        ModuleComponentSelector failureComponentSelector = DefaultModuleComponentSelector.newSelector(failureSelector.getModule(), failureSelector.getVersion());
        root.addDependency(dependencyResultFactory.createUnresolvedDependency(failureComponentSelector, root, true, ComponentSelectionReasons.of(DEPENDENCY_LOCKING), new ModuleVersionResolveException(failureComponentSelector, () -> "Dependency lock state out of date", failure.getProblem())));
    }
}
Also used : ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) UnresolvedDependency(org.gradle.api.artifacts.UnresolvedDependency) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) DefaultResolvedComponentResult(org.gradle.api.internal.artifacts.result.DefaultResolvedComponentResult)

Example 27 with ModuleVersionResolveException

use of org.gradle.internal.resolve.ModuleVersionResolveException in project gradle by gradle.

the class DependencyResultSerializer method read.

public ResolvedGraphDependency read(Decoder decoder, Map<Long, ComponentSelector> selectors, Map<ComponentSelector, ModuleVersionResolveException> failures) throws IOException {
    Long selectorId = decoder.readSmallLong();
    ComponentSelector requested = selectors.get(selectorId);
    boolean constraint = decoder.readBoolean();
    ResolvedVariantResult fromVariant = resolvedVariantResultSerializer.read(decoder);
    byte resultByte = decoder.readByte();
    if (resultByte == SUCCESSFUL) {
        Long selectedId = decoder.readSmallLong();
        return new DetachedResolvedGraphDependency(requested, selectedId, null, null, constraint, fromVariant, resolvedVariantResultSerializer.read(decoder));
    } else if (resultByte == FAILED) {
        ComponentSelectionReason reason = componentSelectionReasonSerializer.read(decoder);
        ModuleVersionResolveException failure = failures.get(requested);
        return new DetachedResolvedGraphDependency(requested, null, reason, failure, constraint, fromVariant, null);
    } else {
        throw new IllegalArgumentException("Unknown result type: " + resultByte);
    }
}
Also used : ComponentSelectionReason(org.gradle.api.artifacts.result.ComponentSelectionReason) ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) ResolvedVariantResult(org.gradle.api.artifacts.result.ResolvedVariantResult) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException)

Example 28 with ModuleVersionResolveException

use of org.gradle.internal.resolve.ModuleVersionResolveException in project gradle by gradle.

the class CompositeBuildDependencySubstitutions method getReplacementFor.

private ProjectComponentIdentifier getReplacementFor(ModuleComponentSelector selector) {
    ModuleIdentifier candidateId = selector.getModuleIdentifier();
    Collection<ProjectComponentIdentifier> providingProjects = replacementMap.get(candidateId);
    if (providingProjects.isEmpty()) {
        LOGGER.debug("Found no composite build substitute for module '{}'.", candidateId);
        return null;
    }
    if (providingProjects.size() == 1) {
        ProjectComponentIdentifier match = providingProjects.iterator().next();
        LOGGER.info("Found project '{}' as substitute for module '{}'.", match, candidateId);
        return match;
    }
    throw new ModuleVersionResolveException(selector, () -> {
        SortedSet<String> sortedProjects = providingProjects.stream().map(ComponentIdentifier::getDisplayName).collect(Collectors.toCollection(TreeSet::new));
        return String.format("Module version '%s' is not unique in composite: can be provided by %s.", selector.getDisplayName(), sortedProjects);
    });
}
Also used : ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Aggregations

ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)28 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)7 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)7 LocalComponentMetadata (org.gradle.internal.component.local.model.LocalComponentMetadata)7 ProjectComponentSelector (org.gradle.api.artifacts.component.ProjectComponentSelector)5 DefaultProjectComponentSelector (org.gradle.internal.component.local.model.DefaultProjectComponentSelector)5 ArrayList (java.util.ArrayList)4 ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)4 DependencySubstitutionInternal (org.gradle.api.internal.artifacts.DependencySubstitutionInternal)3 ComponentResolveMetadata (org.gradle.internal.component.model.ComponentResolveMetadata)3 File (java.io.File)2 ComponentMetadataDetails (org.gradle.api.artifacts.ComponentMetadataDetails)2 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)2 ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)2 BuildIdentifier (org.gradle.api.artifacts.component.BuildIdentifier)2 DependencySubstitutionApplicator (org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DependencySubstitutionApplicator)2 ImmutableAttributes (org.gradle.api.internal.attributes.ImmutableAttributes)2 Pair (org.gradle.internal.Pair)2 ModuleComponentResolveMetadata (org.gradle.internal.component.external.model.ModuleComponentResolveMetadata)2 MutableModuleComponentResolveMetadata (org.gradle.internal.component.external.model.MutableModuleComponentResolveMetadata)2