use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ExcludeSpec in project gradle by gradle.
the class PotentialEdge method of.
static PotentialEdge of(ResolveState resolveState, NodeState from, ModuleComponentIdentifier toComponent, ModuleComponentSelector toSelector, ComponentIdentifier owner, boolean force, boolean transitive) {
DependencyState dependencyState = new DependencyState(new LenientPlatformDependencyMetadata(resolveState, from, toSelector, toComponent, owner, force || hasStrongOpinion(from), transitive), resolveState.getComponentSelectorConverter());
dependencyState = NodeState.maybeSubstitute(dependencyState, resolveState.getDependencySubstitutionApplicator());
ExcludeSpec exclusions = from.previousTraversalExclusions;
if (exclusions == null) {
exclusions = resolveState.getModuleExclusions().nothing();
}
EdgeState edge = new EdgeState(from, dependencyState, exclusions, resolveState);
edge.computeSelector();
ModuleVersionIdentifier toModuleVersionId = DefaultModuleVersionIdentifier.newId(toSelector.getModuleIdentifier(), toSelector.getVersion());
ComponentState version = resolveState.getModule(toSelector.getModuleIdentifier()).getVersion(toModuleVersionId, toComponent);
// We need to check if the target version exists. For this, we have to try to get metadata for the aligned version.
// If it's there, it means we can align, otherwise, we must NOT add the edge, or resolution would fail
ComponentResolveMetadata metadata = version.getMetadata();
return new PotentialEdge(edge, toModuleVersionId, metadata, version);
}
use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ExcludeSpec in project gradle by gradle.
the class EdgeState method computeExclusionsWhenExcludesPresent.
private void computeExclusionsWhenExcludesPresent(List<ExcludeMetadata> excludes) {
ModuleExclusions moduleExclusions = resolveState.getModuleExclusions();
ExcludeSpec edgeExclusions = moduleExclusions.excludeAny(excludes);
cachedExclusions = moduleExclusions.excludeAny(edgeExclusions, transitiveExclusions);
}
use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ExcludeSpec in project gradle by gradle.
the class DefaultArtifactSet method toResolvedVariant.
public static ResolvedVariant toResolvedVariant(VariantResolveMetadata variant, ModuleVersionIdentifier ownerId, ModuleSources moduleSources, ExcludeSpec exclusions, ArtifactResolver artifactResolver, Map<ComponentArtifactIdentifier, ResolvableArtifact> allResolvedArtifacts, ImmutableAttributes variantAttributes, CalculatedValueContainerFactory calculatedValueContainerFactory) {
List<? extends ComponentArtifactMetadata> artifacts = variant.getArtifacts();
ImmutableSet.Builder<ResolvableArtifact> resolvedArtifacts = ImmutableSet.builder();
boolean hasExcludedArtifact = false;
for (ComponentArtifactMetadata artifact : artifacts) {
IvyArtifactName artifactName = artifact.getName();
if (exclusions.excludesArtifact(ownerId.getModule(), artifactName)) {
hasExcludedArtifact = true;
continue;
}
ResolvableArtifact resolvedArtifact = allResolvedArtifacts.get(artifact.getId());
if (resolvedArtifact == null) {
if (artifact.isOptionalArtifact()) {
DefaultBuildableArtifactResolveResult result = new DefaultBuildableArtifactResolveResult();
artifactResolver.resolveArtifact(artifact, moduleSources, result);
if (!result.isSuccessful()) {
// Optional artifact is not available
continue;
}
}
ValueCalculator<File> artifactCalculator;
if (artifactResolver instanceof ProjectArtifactResolver) {
artifactCalculator = ((ProjectArtifactResolver) artifactResolver).resolveArtifactLater(artifact);
} else {
// TODO - push this up to all ArtifactResolver implementations
artifactCalculator = new LazyArtifactSupplier(artifact, moduleSources, artifactResolver);
}
CalculatedValue<File> artifactSource = calculatedValueContainerFactory.create(Describables.of(artifact.getId()), artifactCalculator);
resolvedArtifact = new DefaultResolvableArtifact(ownerId, artifactName, artifact.getId(), context -> context.add(artifact.getBuildDependencies()), artifactSource, calculatedValueContainerFactory);
allResolvedArtifacts.put(artifact.getId(), resolvedArtifact);
}
resolvedArtifacts.add(resolvedArtifact);
}
VariantResolveMetadata.Identifier identifier = variant.getIdentifier();
if (hasExcludedArtifact) {
// An ad hoc variant, has no identifier
identifier = null;
}
return ArtifactBackedResolvedVariant.create(identifier, variant.asDescribable(), variantAttributes, withImplicitCapability(variant, ownerId), resolvedArtifacts.build());
}
use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ExcludeSpec 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();
ImmutableAttributes overriddenAttributes = dependency.getAttributes();
List<? extends ComponentArtifactMetadata> artifacts = dependency.getArtifacts(targetConfiguration);
if (!artifacts.isEmpty()) {
int id = nextId++;
ArtifactSet artifactSet = artifactSelector.resolveArtifacts(component, artifacts, overriddenAttributes);
return new ArtifactsForNode(id, artifactSet);
}
ArtifactsForNode configurationArtifactSet = artifactsByNodeId.get(toConfiguration.getNodeId());
if (configurationArtifactSet == null) {
ExcludeSpec exclusions = dependency.getExclusions();
ArtifactSet nodeArtifacts = artifactSelector.resolveArtifacts(component, targetConfiguration, exclusions, overriddenAttributes);
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;
}
use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ExcludeSpec in project gradle by gradle.
the class NormalizingExcludeFactory method doIntersect.
private ExcludeSpec doIntersect(Set<ExcludeSpec> specs) {
specs = simplifySet(ExcludeAnyOf.class, specs);
FlattenOperationResult flattened = flatten(ExcludeAllOf.class, specs, ExcludeNothing.class::isInstance, ExcludeEverything.class::isInstance);
if (flattened.fastExit) {
return nothing();
}
Set<ExcludeSpec> result = flattened.result;
if (result.isEmpty()) {
return everything();
}
if (result.size() > 1) {
// try simplify
ExcludeSpec[] asArray = result.toArray(new ExcludeSpec[0]);
boolean simplified = false;
for (int i = 0; i < asArray.length; i++) {
ExcludeSpec left = asArray[i];
if (left != null) {
for (int j = 0; j < asArray.length; j++) {
ExcludeSpec right = asArray[j];
if (right != null && i != j) {
ExcludeSpec merged = intersections.tryIntersect(left, right);
if (merged != null) {
if (merged instanceof ExcludeNothing) {
return merged;
}
left = merged;
asArray[i] = merged;
asArray[j] = null;
simplified = true;
}
}
}
}
}
if (simplified) {
result = Arrays.stream(asArray).filter(Objects::nonNull).collect(toSet());
}
}
return Optimizations.optimizeCollection(this, result, delegate::allOf);
}
Aggregations