use of org.gradle.internal.component.model.DefaultVariantMetadata in project gradle by gradle.
the class ResolvedArtifactsGraphVisitor method getArtifacts.
private ArtifactSet getArtifacts(DependencyGraphEdge dependency, DependencyGraphNode toConfiguration) {
long id = idGenerator.generateId();
ConfigurationMetadata configuration = toConfiguration.getMetadata();
ComponentResolveMetadata component = toConfiguration.getOwner().getMetadata();
Set<? extends ComponentArtifactMetadata> artifacts = dependency.getArtifacts(configuration);
if (!artifacts.isEmpty()) {
Set<DefaultVariantMetadata> variants = ImmutableSet.of(new DefaultVariantMetadata(ImmutableAttributes.EMPTY, artifacts));
return new DefaultArtifactSet(component.getComponentId(), component.getId(), component.getSource(), ModuleExclusions.excludeNone(), variants, artifactResolver, allResolvedArtifacts, id, attributesFactory, buildOperationExecutor);
}
ArtifactSet configurationArtifactSet = artifactSetsByConfiguration.get(toConfiguration.getNodeId());
if (configurationArtifactSet == null) {
Set<? extends VariantMetadata> variants = doResolve(component, configuration);
configurationArtifactSet = new DefaultArtifactSet(component.getComponentId(), component.getId(), component.getSource(), dependency.getExclusions(moduleExclusions), variants, artifactResolver, allResolvedArtifacts, id, attributesFactory, buildOperationExecutor);
// Only share an ArtifactSet if the artifacts are not filtered by the dependency
if (!dependency.getExclusions(moduleExclusions).mayExcludeArtifacts()) {
artifactSetsByConfiguration.put(toConfiguration.getNodeId(), configurationArtifactSet);
}
}
return configurationArtifactSet;
}
use of org.gradle.internal.component.model.DefaultVariantMetadata in project gradle by gradle.
the class DefaultLocalComponentMetadata method copy.
/**
* Creates a copy of this metadata, transforming the artifacts and dependencies of this component.
*/
public DefaultLocalComponentMetadata copy(ComponentIdentifier componentIdentifier, Transformer<LocalComponentArtifactMetadata, LocalComponentArtifactMetadata> artifacts, Transformer<LocalOriginDependencyMetadata, LocalOriginDependencyMetadata> dependencies) {
DefaultLocalComponentMetadata copy = new DefaultLocalComponentMetadata(id, componentIdentifier, status, attributesSchema);
for (DefaultLocalConfigurationMetadata configuration : allConfigurations.values()) {
copy.addConfiguration(configuration.getName(), configuration.description, configuration.extendsFrom, configuration.hierarchy, configuration.visible, configuration.transitive, configuration.attributes, configuration.canBeConsumed, configuration.canBeResolved);
}
// Artifacts
// Keep track of transformed artifacts as a given artifact may appear in multiple variants
Map<LocalComponentArtifactMetadata, LocalComponentArtifactMetadata> transformedArtifacts = new HashMap<LocalComponentArtifactMetadata, LocalComponentArtifactMetadata>();
for (Map.Entry<String, LocalComponentArtifactMetadata> entry : allArtifacts.entries()) {
LocalComponentArtifactMetadata oldArtifact = entry.getValue();
LocalComponentArtifactMetadata newArtifact = copyArtifact(oldArtifact, artifacts, transformedArtifacts);
copy.allArtifacts.put(entry.getKey(), newArtifact);
}
// Variants
for (Map.Entry<String, DefaultVariantMetadata> entry : allVariants.entries()) {
DefaultVariantMetadata oldVariant = entry.getValue();
Set<LocalComponentArtifactMetadata> newArtifacts = new LinkedHashSet<LocalComponentArtifactMetadata>(oldVariant.getArtifacts().size());
for (ComponentArtifactMetadata oldArtifact : oldVariant.getArtifacts()) {
newArtifacts.add(copyArtifact((LocalComponentArtifactMetadata) oldArtifact, artifacts, transformedArtifacts));
}
copy.allVariants.put(entry.getKey(), new DefaultVariantMetadata(oldVariant.getAttributes(), newArtifacts));
}
// Dependencies
for (LocalOriginDependencyMetadata oldDependency : allDependencies) {
copy.allDependencies.add(dependencies.transform(oldDependency));
}
// Exclude rules
copy.allExcludes.addAll(allExcludes);
return copy;
}
use of org.gradle.internal.component.model.DefaultVariantMetadata in project gradle by gradle.
the class DefaultLocalComponentMetadata method addVariant.
@Override
public void addVariant(String configuration, OutgoingVariant variant) {
Set<LocalComponentArtifactMetadata> artifacts;
if (variant.getArtifacts().isEmpty()) {
artifacts = ImmutableSet.of();
} else {
ImmutableSet.Builder<LocalComponentArtifactMetadata> builder = ImmutableSet.builder();
for (PublishArtifact artifact : variant.getArtifacts()) {
builder.add(new PublishArtifactLocalArtifactMetadata(componentIdentifier, artifact));
}
artifacts = builder.build();
}
allVariants.put(configuration, new DefaultVariantMetadata(variant.getAttributes().asImmutable(), artifacts));
}
Aggregations