use of org.gradle.internal.component.model.VariantResolveMetadata in project gradle by gradle.
the class DefaultArtifactSet method multipleVariants.
public static ArtifactSet multipleVariants(ComponentIdentifier componentIdentifier, ModuleVersionIdentifier ownerId, ModuleSource moduleSource, ModuleExclusion exclusions, Set<? extends VariantResolveMetadata> variants, AttributesSchemaInternal schema, ArtifactResolver artifactResolver, Map<ComponentArtifactIdentifier, ResolvableArtifact> allResolvedArtifacts, ArtifactTypeRegistry artifactTypeRegistry) {
if (variants.size() == 1) {
VariantResolveMetadata variantMetadata = variants.iterator().next();
ResolvedVariant resolvedVariant = toResolvedVariant(variantMetadata, ownerId, moduleSource, exclusions, artifactResolver, allResolvedArtifacts, artifactTypeRegistry);
return new SingleVariantAttributeSet(componentIdentifier, schema, resolvedVariant);
}
ImmutableSet.Builder<ResolvedVariant> result = ImmutableSet.builder();
for (VariantResolveMetadata variant : variants) {
ResolvedVariant resolvedVariant = toResolvedVariant(variant, ownerId, moduleSource, exclusions, artifactResolver, allResolvedArtifacts, artifactTypeRegistry);
result.add(resolvedVariant);
}
return new MultipleVariantAttributeSet(componentIdentifier, schema, result.build());
}
use of org.gradle.internal.component.model.VariantResolveMetadata in project gradle by gradle.
the class DefaultArtifactSet method singleVariant.
public static ArtifactSet singleVariant(ComponentIdentifier componentIdentifier, ModuleVersionIdentifier ownerId, DisplayName displayName, Collection<? extends ComponentArtifactMetadata> artifacts, ModuleSource moduleSource, ModuleExclusion exclusions, AttributesSchemaInternal schema, ArtifactResolver artifactResolver, Map<ComponentArtifactIdentifier, ResolvableArtifact> allResolvedArtifacts, ArtifactTypeRegistry artifactTypeRegistry) {
VariantResolveMetadata variantMetadata = new DefaultVariantMetadata(displayName, ImmutableAttributes.EMPTY, ImmutableList.copyOf(artifacts), ImmutableCapabilities.EMPTY);
ResolvedVariant resolvedVariant = toResolvedVariant(variantMetadata, ownerId, moduleSource, exclusions, artifactResolver, allResolvedArtifacts, artifactTypeRegistry);
return new SingleVariantAttributeSet(componentIdentifier, schema, resolvedVariant);
}
use of org.gradle.internal.component.model.VariantResolveMetadata in project gradle by gradle.
the class DependencyResolvingClasspath method resolve.
private ResolveResult resolve() {
ResolveResult result = new ResolveResult();
dependencyResolver.resolve(resolveContext, remoteRepositories, globalRules, Specs.<DependencyMetadata>satisfyAll(), result, result, attributesSchema, new ArtifactTypeRegistry() {
@Override
public ImmutableAttributes mapAttributesFor(File file) {
return ImmutableAttributes.EMPTY;
}
@Override
public ImmutableAttributes mapAttributesFor(VariantResolveMetadata variant) {
return variant.getAttributes().asImmutable();
}
@Override
public ArtifactTypeContainer create() {
throw new UnsupportedOperationException();
}
});
return result;
}
use of org.gradle.internal.component.model.VariantResolveMetadata 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.internal.component.model.VariantResolveMetadata in project gradle by gradle.
the class DefaultArtifactSet method createForConfiguration.
public static ArtifactSet createForConfiguration(ComponentIdentifier componentIdentifier, ModuleVersionIdentifier ownerId, ConfigurationMetadata configuration, ImmutableList<? extends ComponentArtifactMetadata> artifacts, ModuleSources moduleSources, ExcludeSpec exclusions, AttributesSchemaInternal schema, ArtifactResolver artifactResolver, Map<ComponentArtifactIdentifier, ResolvableArtifact> allResolvedArtifacts, ArtifactTypeRegistry artifactTypeRegistry, ImmutableAttributes selectionAttributes, CalculatedValueContainerFactory calculatedValueContainerFactory) {
VariantResolveMetadata variantMetadata = new DefaultVariantMetadata(configuration.getName(), new ComponentConfigurationIdentifier(componentIdentifier, configuration.getName()), configuration.asDescribable(), configuration.getAttributes(), artifacts, configuration.getCapabilities());
ResolvedVariant resolvedVariant = toResolvedVariant(variantMetadata, ownerId, moduleSources, exclusions, artifactResolver, allResolvedArtifacts, artifactTypeRegistry, calculatedValueContainerFactory);
return new SingleVariantArtifactSet(componentIdentifier, schema, resolvedVariant, selectionAttributes);
}
Aggregations