Search in sources :

Example 31 with ComponentIdentifier

use of org.gradle.api.artifacts.component.ComponentIdentifier in project gradle by gradle.

the class ResolvedVariantResultSerializer method read.

@Override
public ResolvedVariantResult read(Decoder decoder) throws IOException {
    int index = decoder.readSmallInt();
    if (index == -1) {
        return null;
    }
    if (index == read.size()) {
        ComponentIdentifier owner = componentIdentifierSerializer.read(decoder);
        String variantName = decoder.readString();
        AttributeContainer attributes = attributeContainerSerializer.read(decoder);
        List<Capability> capabilities = readCapabilities(decoder);
        read.add(null);
        ResolvedVariantResult externalVariant = read(decoder);
        DefaultResolvedVariantResult result = new DefaultResolvedVariantResult(owner, Describables.of(variantName), attributes, capabilities, externalVariant);
        this.read.set(index, result);
        return result;
    }
    return read.get(index);
}
Also used : Capability(org.gradle.api.capabilities.Capability) DefaultResolvedVariantResult(org.gradle.api.internal.artifacts.result.DefaultResolvedVariantResult) DefaultResolvedVariantResult(org.gradle.api.internal.artifacts.result.DefaultResolvedVariantResult) ResolvedVariantResult(org.gradle.api.artifacts.result.ResolvedVariantResult) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) AttributeContainer(org.gradle.api.attributes.AttributeContainer)

Example 32 with ComponentIdentifier

use of org.gradle.api.artifacts.component.ComponentIdentifier in project gradle by gradle.

the class ComponentResultSerializer method read.

@Override
public ResolvedGraphComponent read(Decoder decoder) throws IOException {
    long resultId = decoder.readSmallLong();
    ModuleVersionIdentifier id = idSerializer.read(decoder);
    ComponentSelectionReason reason = reasonSerializer.read(decoder);
    ComponentIdentifier componentId = componentIdSerializer.read(decoder);
    List<ResolvedVariantResult> resolvedVariants = readResolvedVariants(decoder);
    String repositoryName = decoder.readNullableString();
    return new DetachedComponentResult(resultId, id, reason, componentId, resolvedVariants, repositoryName);
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) ComponentSelectionReason(org.gradle.api.artifacts.result.ComponentSelectionReason) ResolvedVariantResult(org.gradle.api.artifacts.result.ResolvedVariantResult) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier)

Example 33 with ComponentIdentifier

use of org.gradle.api.artifacts.component.ComponentIdentifier in project gradle by gradle.

the class AbstractRealisedModuleResolveMetadataSerializationHelper method writeFiles.

protected void writeFiles(Encoder encoder, ImmutableList<? extends ComponentArtifactMetadata> artifacts) throws IOException {
    int fileArtifactsCount = (int) artifacts.stream().filter(a -> a instanceof UrlBackedArtifactMetadata).count();
    int ivyArtifactsCount = artifacts.size() - fileArtifactsCount;
    encoder.writeSmallInt(ivyArtifactsCount);
    for (ComponentArtifactMetadata artifact : artifacts) {
        if (!(artifact instanceof UrlBackedArtifactMetadata)) {
            IvyArtifactName artifactName = artifact.getName();
            writeIvyArtifactName(encoder, artifactName);
            ComponentIdentifier componentId = artifact.getComponentId();
            if (componentId instanceof MavenUniqueSnapshotComponentIdentifier) {
                MavenUniqueSnapshotComponentIdentifier uid = (MavenUniqueSnapshotComponentIdentifier) componentId;
                encoder.writeNullableString(uid.getTimestamp());
                encoder.writeString(uid.getVersion());
            } else {
                encoder.writeNullableString(null);
            }
            encoder.writeBoolean(artifact.getAlternativeArtifact().isPresent());
            if (artifact.getAlternativeArtifact().isPresent()) {
                writeIvyArtifactName(encoder, artifact.getAlternativeArtifact().get().getName());
            }
            encoder.writeBoolean(artifact.isOptionalArtifact());
        }
    }
    encoder.writeSmallInt(fileArtifactsCount);
    for (ComponentArtifactMetadata file : artifacts) {
        if (file instanceof UrlBackedArtifactMetadata) {
            encoder.writeString(((UrlBackedArtifactMetadata) file).getFileName());
            encoder.writeString(((UrlBackedArtifactMetadata) file).getRelativeUrl());
        }
    }
}
Also used : ComponentArtifactMetadata(org.gradle.internal.component.model.ComponentArtifactMetadata) MavenUniqueSnapshotComponentIdentifier(org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) MavenUniqueSnapshotComponentIdentifier(org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier)

Example 34 with ComponentIdentifier

use of org.gradle.api.artifacts.component.ComponentIdentifier in project gradle by gradle.

the class DependencyLockingArtifactVisitor method visitNode.

@Override
public void visitNode(DependencyGraphNode node) {
    boolean changing = false;
    ComponentIdentifier identifier = node.getOwner().getComponentId();
    ComponentResolveMetadata metadata = node.getOwner().getMetadata();
    if (metadata != null && metadata.isChanging()) {
        changing = true;
    }
    if (!node.isRoot() && identifier instanceof ModuleComponentIdentifier) {
        ModuleComponentIdentifier id = (ModuleComponentIdentifier) identifier;
        if (identifier instanceof MavenUniqueSnapshotComponentIdentifier) {
            id = ((MavenUniqueSnapshotComponentIdentifier) id).getSnapshotComponent();
        }
        if (!id.getVersion().isEmpty()) {
            if (allResolvedModules.add(id)) {
                if (changing) {
                    addChangingModule(id);
                }
                if (dependencyLockingState.mustValidateLockState()) {
                    ModuleComponentIdentifier lockedId = modulesToBeLocked.remove(id.getModuleIdentifier());
                    if (lockedId == null) {
                        if (!dependencyLockingState.getIgnoredEntryFilter().isSatisfiedBy(id)) {
                            extraModules.add(id);
                        }
                    } else if (!lockedId.getVersion().equals(id.getVersion()) && !isNodeRejected(node)) {
                        // Need to check that versions do match, mismatch indicates a force was used
                        forcedModules.put(lockedId, id.getVersion());
                    }
                }
            }
        }
    }
}
Also used : MavenUniqueSnapshotComponentIdentifier(org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) MavenUniqueSnapshotComponentIdentifier(org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) ComponentResolveMetadata(org.gradle.internal.component.model.ComponentResolveMetadata)

Example 35 with ComponentIdentifier

use of org.gradle.api.artifacts.component.ComponentIdentifier in project gradle by gradle.

the class JsonProjectDependencyRenderer method populateModulesWithChildDependencies.

private void populateModulesWithChildDependencies(RenderableDependency dependency, Set<ComponentIdentifier> visited, Set<ModuleIdentifier> modules) {
    for (RenderableDependency childDependency : dependency.getChildren()) {
        ModuleIdentifier moduleId = getModuleIdentifier(childDependency);
        if (moduleId == null) {
            continue;
        }
        modules.add(moduleId);
        boolean alreadyVisited = !visited.add((ComponentIdentifier) childDependency.getId());
        if (!alreadyVisited) {
            populateModulesWithChildDependencies(childDependency, visited, modules);
        }
    }
}
Also used : RenderableDependency(org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Aggregations

ComponentIdentifier (org.gradle.api.artifacts.component.ComponentIdentifier)39 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)17 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)15 File (java.io.File)14 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)10 OpaqueComponentArtifactIdentifier (org.gradle.internal.component.local.model.OpaqueComponentArtifactIdentifier)7 NonNull (com.android.annotations.NonNull)6 ArtifactCollection (org.gradle.api.artifacts.ArtifactCollection)6 ResolvedArtifactResult (org.gradle.api.artifacts.result.ResolvedArtifactResult)6 FilteredArtifactCollection (com.android.build.gradle.internal.dependency.FilteredArtifactCollection)5 DependencyResult (org.gradle.api.artifacts.result.DependencyResult)5 ResolvedComponentResult (org.gradle.api.artifacts.result.ResolvedComponentResult)5 ResolvedDependencyResult (org.gradle.api.artifacts.result.ResolvedDependencyResult)5 Module (org.gradle.api.internal.artifacts.Module)5 ResolvedArtifact (org.gradle.api.artifacts.ResolvedArtifact)4 ComponentArtifactIdentifier (org.gradle.api.artifacts.component.ComponentArtifactIdentifier)4 ResolutionResult (org.gradle.api.artifacts.result.ResolutionResult)4 ResolvedVariantResult (org.gradle.api.artifacts.result.ResolvedVariantResult)4 UnresolvedDependencyResult (org.gradle.api.artifacts.result.UnresolvedDependencyResult)4 DefaultModuleComponentIdentifier (org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier)4