use of org.gradle.api.internal.artifacts.DefaultResolvedArtifact in project gradle by gradle.
the class DefaultArtifactSet method snapshot.
@Override
public ArtifactSet snapshot() {
ImmutableSet.Builder<ResolvedVariant> result = ImmutableSet.builder();
for (VariantMetadata variant : variants) {
Set<? extends ComponentArtifactMetadata> artifacts = variant.getArtifacts();
Set<ResolvedArtifact> resolvedArtifacts = new LinkedHashSet<ResolvedArtifact>(artifacts.size());
// Add artifact format as an implicit attribute when all artifacts have the same format
AttributeContainerInternal attributes = variant.getAttributes();
if (!attributes.contains(ArtifactAttributes.ARTIFACT_FORMAT)) {
String format = null;
for (ComponentArtifactMetadata artifact : artifacts) {
String candidateFormat = artifact.getName().getType();
if (format == null) {
format = candidateFormat;
} else if (!format.equals(candidateFormat)) {
format = null;
break;
}
}
if (format != null) {
attributes = attributesFactory.concat(attributes.asImmutable(), ArtifactAttributes.ARTIFACT_FORMAT, format);
}
}
for (ComponentArtifactMetadata artifact : artifacts) {
IvyArtifactName artifactName = artifact.getName();
if (exclusions.excludeArtifact(moduleVersionIdentifier.getModule(), artifactName)) {
continue;
}
ResolvedArtifact resolvedArtifact = allResolvedArtifacts.get(artifact.getId());
if (resolvedArtifact == null) {
Factory<File> artifactSource = new BuildOperationArtifactSource(buildOperationExecutor, artifact.getId(), new LazyArtifactSource(artifact, moduleSource, artifactResolver));
resolvedArtifact = new DefaultResolvedArtifact(moduleVersionIdentifier, artifactName, artifact.getId(), artifact.getBuildDependencies(), artifactSource);
allResolvedArtifacts.put(artifact.getId(), resolvedArtifact);
}
resolvedArtifacts.add(resolvedArtifact);
}
result.add(ArtifactBackedResolvedVariant.create(attributes, resolvedArtifacts));
}
return new ArtifactSetSnapshot(id, componentIdentifier, result.build());
}
Aggregations