use of org.gradle.internal.model.CalculatedValueContainerFactory 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());
}
Aggregations