Search in sources :

Example 31 with ModuleIdentifier

use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.

the class Unions method tryGroupUnion.

private ExcludeSpec tryGroupUnion(GroupExclude left, ExcludeSpec right) {
    String leftGroup = left.getGroup();
    if (right instanceof ModuleIdExclude) {
        ModuleIdExclude mie = (ModuleIdExclude) right;
        if (mie.getModuleId().getGroup().equals(leftGroup)) {
            return left;
        }
    }
    if (right instanceof ModuleIdSetExclude) {
        ModuleIdSetExclude ids = (ModuleIdSetExclude) right;
        Set<ModuleIdentifier> items = ids.getModuleIds().stream().filter(id -> !id.getGroup().equals(leftGroup)).collect(Collectors.toSet());
        if (items.size() == 1) {
            return factory.anyOf(left, factory.moduleId(items.iterator().next()));
        }
        if (items.isEmpty()) {
            return left;
        }
        if (items.size() != ids.getModuleIds().size()) {
            return factory.anyOf(left, factory.moduleIdSet(items));
        }
    }
    return null;
}
Also used : GroupExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.GroupExclude) ModuleSetExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleSetExclude) ModuleIdExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleIdExclude) GroupSetExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.GroupSetExclude) ModuleExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleExclude) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) ModuleIdSetExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleIdSetExclude) Set(java.util.Set) ExcludeSpec(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ExcludeSpec) Collectors(java.util.stream.Collectors) ModuleIdExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleIdExclude) ModuleIdSetExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleIdSetExclude) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 32 with ModuleIdentifier

use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.

the class Unions method tryModuleSetUnion.

private ExcludeSpec tryModuleSetUnion(ModuleSetExclude left, ExcludeSpec right) {
    Set<String> leftModules = left.getModules();
    if (right instanceof ModuleIdExclude) {
        ModuleIdExclude mie = (ModuleIdExclude) right;
        if (leftModules.contains(mie.getModuleId().getName())) {
            return left;
        }
    }
    if (right instanceof ModuleIdSetExclude) {
        ModuleIdSetExclude ids = (ModuleIdSetExclude) right;
        Set<ModuleIdentifier> items = ids.getModuleIds().stream().filter(id -> !leftModules.contains(id.getName())).collect(Collectors.toSet());
        if (items.size() == 1) {
            return factory.anyOf(left, factory.moduleId(items.iterator().next()));
        }
        if (items.isEmpty()) {
            return left;
        }
        if (items.size() != ids.getModuleIds().size()) {
            return factory.anyOf(left, factory.moduleIdSet(items));
        }
    }
    return null;
}
Also used : GroupExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.GroupExclude) ModuleSetExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleSetExclude) ModuleIdExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleIdExclude) GroupSetExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.GroupSetExclude) ModuleExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleExclude) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) ModuleIdSetExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleIdSetExclude) Set(java.util.Set) ExcludeSpec(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ExcludeSpec) Collectors(java.util.stream.Collectors) ModuleIdExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleIdExclude) ModuleIdSetExclude(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleIdSetExclude) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 33 with ModuleIdentifier

use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.

the class MessageBuilderHelper method pathTo.

static Collection<String> pathTo(EdgeState edge, boolean includeLast) {
    List<List<EdgeState>> acc = Lists.newArrayListWithExpectedSize(1);
    pathTo(edge, Lists.newArrayList(), acc, Sets.newHashSet());
    List<String> result = Lists.newArrayListWithCapacity(acc.size());
    for (List<EdgeState> path : acc) {
        EdgeState target = Iterators.getLast(path.iterator());
        StringBuilder sb = new StringBuilder();
        if (target.getSelector().getDependencyMetadata().isConstraint()) {
            sb.append("Constraint path ");
        } else {
            sb.append("Dependency path ");
        }
        boolean first = true;
        String variantDetails = null;
        for (EdgeState e : path) {
            if (!first) {
                sb.append(" --> ");
            }
            first = false;
            ModuleVersionIdentifier id = e.getFrom().getResolvedConfigurationId().getId();
            sb.append('\'').append(id).append('\'');
            if (variantDetails != null) {
                sb.append(variantDetails);
            }
            variantDetails = variantDetails(e);
        }
        if (includeLast) {
            sb.append(" --> ");
            SelectorState selector = edge.getSelector();
            ModuleIdentifier moduleId = selector.getTargetModule().getId();
            sb.append('\'').append(moduleId.getGroup()).append(':').append(moduleId.getName()).append('\'');
            if (variantDetails != null) {
                sb.append(variantDetails);
            }
        }
        result.add(sb.toString());
    }
    return result;
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) List(java.util.List) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 34 with ModuleIdentifier

use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.

the class NodeState method visitAdditionalConstraints.

/**
 * Iterate over the dependencies originating in this node, adding only the constraints listed
 * in upcomingNoLongerPendingConstraints
 */
private void visitAdditionalConstraints(Collection<EdgeState> discoveredEdges) {
    if (potentiallyActivatedConstraints == null) {
        return;
    }
    for (ModuleIdentifier module : upcomingNoLongerPendingConstraints) {
        Collection<DependencyState> dependencyStates = potentiallyActivatedConstraints.get(module);
        if (!dependencyStates.isEmpty()) {
            for (DependencyState dependencyState : dependencyStates) {
                dependencyState = maybeSubstitute(dependencyState, resolveState.getDependencySubstitutionApplicator());
                createAndLinkEdgeState(dependencyState, discoveredEdges, previousTraversalExclusions, false);
            }
        }
    }
    upcomingNoLongerPendingConstraints = null;
}
Also used : ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 35 with ModuleIdentifier

use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.

the class ResolveState method getSelector.

public SelectorState getSelector(DependencyState dependencyState, boolean ignoreVersion) {
    boolean isVirtualPlatformEdge = dependencyState.getDependency() instanceof LenientPlatformDependencyMetadata;
    SelectorState selectorState = selectors.computeIfAbsent(new SelectorCacheKey(dependencyState.getRequested(), ignoreVersion, isVirtualPlatformEdge), req -> {
        ModuleIdentifier moduleIdentifier = dependencyState.getModuleIdentifier();
        return new SelectorState(idGenerator.generateId(), dependencyState, idResolver, this, moduleIdentifier, ignoreVersion);
    });
    selectorState.update(dependencyState);
    return selectorState;
}
Also used : ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Aggregations

ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)46 DefaultModuleIdentifier (org.gradle.api.internal.artifacts.DefaultModuleIdentifier)8 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)7 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)5 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)5 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 ExcludeSpec (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ExcludeSpec)4 GroupExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.GroupExclude)4 GroupSetExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.GroupSetExclude)4 ModuleExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleExclude)4 ModuleIdExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleIdExclude)4 ModuleIdSetExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleIdSetExclude)4 ModuleSetExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleSetExclude)4 LinkedHashSet (java.util.LinkedHashSet)3 Action (org.gradle.api.Action)3 InvalidUserCodeException (org.gradle.api.InvalidUserCodeException)3 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)3 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)3 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)3