Search in sources :

Example 1 with ModuleExclusion

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ModuleExclusion in project gradle by gradle.

the class ResolvedArtifactsGraphVisitor method getArtifacts.

private ArtifactsForNode getArtifacts(DependencyGraphEdge dependency, DependencyGraphNode toConfiguration) {
    ConfigurationMetadata targetConfiguration = toConfiguration.getMetadata();
    ComponentResolveMetadata component = toConfiguration.getOwner().getMetadata();
    List<? extends ComponentArtifactMetadata> artifacts = dependency.getArtifacts(targetConfiguration);
    if (!artifacts.isEmpty()) {
        int id = nextId++;
        ArtifactSet artifactSet = artifactSelector.resolveArtifacts(component, artifacts);
        return new ArtifactsForNode(id, artifactSet);
    }
    ArtifactsForNode configurationArtifactSet = artifactsByNodeId.get(toConfiguration.getNodeId());
    if (configurationArtifactSet == null) {
        ModuleExclusion exclusions = dependency.getExclusions();
        // The above isn't quite right, since we are not applying artifact exclusions defined for the target node,
        // to the target node itself. So a module exclusion for `type='jar'` won't exclude the jar for the module itself.
        // While fixing this, we should be smarter about artifact exclusions: these can be completely separate from module exclusions.
        // ModuleExclusion nodeExclusions = targetConfiguration.getExclusions(moduleExclusions);
        // ModuleExclusion edgeExclusions = dependency.getExclusions();
        // ModuleExclusion exclusions = moduleExclusions.intersect(edgeExclusions, nodeExclusions);
        ArtifactSet nodeArtifacts = artifactSelector.resolveArtifacts(component, targetConfiguration, exclusions);
        int id = nextId++;
        configurationArtifactSet = new ArtifactsForNode(id, nodeArtifacts);
        // Only share an ArtifactSet if the artifacts are not filtered by the dependency
        if (!exclusions.mayExcludeArtifacts()) {
            artifactsByNodeId.put(toConfiguration.getNodeId(), configurationArtifactSet);
        }
    }
    return configurationArtifactSet;
}
Also used : ModuleExclusion(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ModuleExclusion) ComponentResolveMetadata(org.gradle.internal.component.model.ComponentResolveMetadata) ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata)

Example 2 with ModuleExclusion

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ModuleExclusion in project gradle by gradle.

the class EdgeState method getExclusions.

@Override
public ModuleExclusion getExclusions() {
    List<ExcludeMetadata> excludes = dependencyMetadata.getExcludes();
    if (excludes.isEmpty()) {
        return transitiveExclusions;
    }
    ModuleExclusion edgeExclusions = resolveState.getModuleExclusions().excludeAny(ImmutableList.copyOf(excludes));
    return resolveState.getModuleExclusions().intersect(edgeExclusions, transitiveExclusions);
}
Also used : ModuleExclusion(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ModuleExclusion) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata)

Example 3 with ModuleExclusion

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ModuleExclusion in project gradle by gradle.

the class NodeState method visitOutgoingDependencies.

/**
 * Visits all of the dependencies that originate on this node, adding them as outgoing edges.
 * The {@link #outgoingEdges} collection is populated, as is the `discoveredEdges` parameter.
 * @param discoveredEdges A collector for visited edges.
 * @param pendingDependenciesHandler Handler for pending dependencies.
 */
public void visitOutgoingDependencies(Collection<EdgeState> discoveredEdges, PendingDependenciesHandler pendingDependenciesHandler) {
    if (!component.isSelected()) {
        LOGGER.debug("version for {} is not selected. ignoring.", this);
        return;
    }
    // Check if this node is still included in the graph, by looking at incoming edges.
    boolean hasIncomingEdges = !incomingEdges.isEmpty();
    List<EdgeState> transitiveIncoming = getTransitiveIncomingEdges();
    // Check if there are any transitive incoming edges at all. Don't traverse if not.
    if (transitiveIncoming.isEmpty() && !isRoot()) {
        // If node was previously traversed, need to remove outgoing edges.
        if (previousTraversalExclusions != null) {
            removeOutgoingEdges();
        }
        if (hasIncomingEdges) {
            LOGGER.debug("{} has no transitive incoming edges. ignoring outgoing edges.", this);
        } else {
            LOGGER.debug("{} has no incoming edges. ignoring.", this);
        }
        return;
    }
    // Determine the net exclusion for this node, by inspecting all transitive incoming edges
    ModuleExclusion resolutionFilter = getModuleResolutionFilter(transitiveIncoming);
    // Check if the was previously traversed with the same net exclusion
    if (previousTraversalExclusions != null && previousTraversalExclusions.excludesSameModulesAs(resolutionFilter)) {
        // Was previously traversed, and no change to the set of modules that are linked by outgoing edges.
        // Don't need to traverse again, but hang on to the new filter since it may change the set of excluded artifacts.
        LOGGER.debug("Changed edges for {} selects same versions as previous traversal. ignoring", this);
        previousTraversalExclusions = resolutionFilter;
        return;
    }
    // Clear previous traversal state, if any
    if (previousTraversalExclusions != null) {
        removeOutgoingEdges();
    }
    visitDependencies(resolutionFilter, pendingDependenciesHandler, discoveredEdges);
}
Also used : ModuleExclusion(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ModuleExclusion)

Example 4 with ModuleExclusion

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ModuleExclusion in project gradle by gradle.

the class NodeState method getModuleResolutionFilter.

private ModuleExclusion getModuleResolutionFilter(List<EdgeState> incomingEdges) {
    ModuleExclusions moduleExclusions = resolveState.getModuleExclusions();
    ModuleExclusion nodeExclusions = moduleExclusions.excludeAny(metaData.getExcludes());
    if (incomingEdges.isEmpty()) {
        return nodeExclusions;
    }
    ModuleExclusion edgeExclusions = incomingEdges.get(0).getExclusions();
    for (int i = 1; i < incomingEdges.size(); i++) {
        EdgeState dependencyEdge = incomingEdges.get(i);
        edgeExclusions = moduleExclusions.union(edgeExclusions, dependencyEdge.getExclusions());
    }
    return moduleExclusions.intersect(edgeExclusions, nodeExclusions);
}
Also used : ModuleExclusions(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ModuleExclusions) ModuleExclusion(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ModuleExclusion)

Aggregations

ModuleExclusion (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ModuleExclusion)4 ModuleExclusions (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ModuleExclusions)1 ComponentResolveMetadata (org.gradle.internal.component.model.ComponentResolveMetadata)1 ConfigurationMetadata (org.gradle.internal.component.model.ConfigurationMetadata)1 ExcludeMetadata (org.gradle.internal.component.model.ExcludeMetadata)1