Search in sources :

Example 1 with ModuleSources

use of org.gradle.internal.component.model.ModuleSources 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());
}
Also used : ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) AttributesSchemaInternal(org.gradle.api.internal.attributes.AttributesSchemaInternal) DefaultResolvableArtifact(org.gradle.api.internal.artifacts.DefaultResolvableArtifact) ComponentArtifactMetadata(org.gradle.internal.component.model.ComponentArtifactMetadata) ModuleSources(org.gradle.internal.component.model.ModuleSources) ExtraExecutionGraphDependenciesResolverFactory(org.gradle.api.internal.artifacts.transform.ExtraExecutionGraphDependenciesResolverFactory) ComponentConfigurationIdentifier(org.gradle.internal.component.model.ComponentConfigurationIdentifier) ValueCalculator(org.gradle.internal.model.ValueCalculator) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) VariantResolveMetadata(org.gradle.internal.component.model.VariantResolveMetadata) ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata) ArtifactResolver(org.gradle.internal.resolve.resolver.ArtifactResolver) Describables(org.gradle.internal.Describables) ImmutableList(com.google.common.collect.ImmutableList) ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) NodeExecutionContext(org.gradle.api.internal.tasks.NodeExecutionContext) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) ImmutableCapabilities(org.gradle.internal.component.external.model.ImmutableCapabilities) Map(java.util.Map) Describable(org.gradle.api.Describable) ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) Nullable(javax.annotation.Nullable) CapabilitiesMetadata(org.gradle.api.capabilities.CapabilitiesMetadata) TransformedVariantFactory(org.gradle.api.internal.artifacts.transform.TransformedVariantFactory) VariantDefinition(org.gradle.api.internal.artifacts.transform.VariantDefinition) ImmutableCapability(org.gradle.internal.component.external.model.ImmutableCapability) CalculatedValue(org.gradle.internal.model.CalculatedValue) ImmutableSet(com.google.common.collect.ImmutableSet) TaskDependencyResolveContext(org.gradle.api.internal.tasks.TaskDependencyResolveContext) ArtifactTypeRegistry(org.gradle.api.internal.artifacts.type.ArtifactTypeRegistry) Collection(java.util.Collection) VariantSelector(org.gradle.api.internal.artifacts.transform.VariantSelector) Set(java.util.Set) ComponentArtifactIdentifier(org.gradle.api.artifacts.component.ComponentArtifactIdentifier) ExcludeSpec(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ExcludeSpec) File(java.io.File) DefaultBuildableArtifactResolveResult(org.gradle.internal.resolve.result.DefaultBuildableArtifactResolveResult) List(java.util.List) CalculatedValueContainerFactory(org.gradle.internal.model.CalculatedValueContainerFactory) Spec(org.gradle.api.specs.Spec) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ProjectArtifactResolver(org.gradle.api.internal.artifacts.ivyservice.projectmodule.ProjectArtifactResolver) DefaultVariantMetadata(org.gradle.internal.component.model.DefaultVariantMetadata) ProjectArtifactResolver(org.gradle.api.internal.artifacts.ivyservice.projectmodule.ProjectArtifactResolver) VariantResolveMetadata(org.gradle.internal.component.model.VariantResolveMetadata) DefaultBuildableArtifactResolveResult(org.gradle.internal.resolve.result.DefaultBuildableArtifactResolveResult) DefaultResolvableArtifact(org.gradle.api.internal.artifacts.DefaultResolvableArtifact) ImmutableSet(com.google.common.collect.ImmutableSet) ComponentArtifactMetadata(org.gradle.internal.component.model.ComponentArtifactMetadata) DefaultResolvableArtifact(org.gradle.api.internal.artifacts.DefaultResolvableArtifact) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) File(java.io.File)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 File (java.io.File)1 Collection (java.util.Collection)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Nullable (javax.annotation.Nullable)1 Describable (org.gradle.api.Describable)1 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)1 ComponentArtifactIdentifier (org.gradle.api.artifacts.component.ComponentArtifactIdentifier)1 ComponentIdentifier (org.gradle.api.artifacts.component.ComponentIdentifier)1 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)1 CapabilitiesMetadata (org.gradle.api.capabilities.CapabilitiesMetadata)1 DefaultResolvableArtifact (org.gradle.api.internal.artifacts.DefaultResolvableArtifact)1 ProjectArtifactResolver (org.gradle.api.internal.artifacts.ivyservice.projectmodule.ProjectArtifactResolver)1 ExcludeSpec (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ExcludeSpec)1 ExtraExecutionGraphDependenciesResolverFactory (org.gradle.api.internal.artifacts.transform.ExtraExecutionGraphDependenciesResolverFactory)1 TransformedVariantFactory (org.gradle.api.internal.artifacts.transform.TransformedVariantFactory)1 VariantDefinition (org.gradle.api.internal.artifacts.transform.VariantDefinition)1