Search in sources :

Example 1 with ExternalDependencyDescriptor

use of org.gradle.internal.component.external.model.ExternalDependencyDescriptor in project gradle by gradle.

the class RealisedMavenModuleResolveMetadataSerializationHelper method writeDependencies.

@Override
protected void writeDependencies(Encoder encoder, ConfigurationMetadata configuration, Map<ExternalDependencyDescriptor, Integer> deduplicationDependencyCache) throws IOException {
    List<? extends DependencyMetadata> dependencies = configuration.getDependencies();
    encoder.writeSmallInt(dependencies.size());
    for (DependencyMetadata dependency : dependencies) {
        if (dependency instanceof ForcedDependencyMetadataWrapper) {
            ForcedDependencyMetadataWrapper wrapper = (ForcedDependencyMetadataWrapper) dependency;
            dependency = wrapper.unwrap();
            if (wrapper.isForce()) {
                encoder.writeByte(FORCED_DEPENDENCY_METADATA);
            }
        }
        if (dependency instanceof GradleDependencyMetadata) {
            encoder.writeByte(GRADLE_DEPENDENCY_METADATA);
            writeDependencyMetadata(encoder, (GradleDependencyMetadata) dependency);
        } else if (dependency instanceof ConfigurationBoundExternalDependencyMetadata) {
            ConfigurationBoundExternalDependencyMetadata dependencyMetadata = (ConfigurationBoundExternalDependencyMetadata) dependency;
            ExternalDependencyDescriptor dependencyDescriptor = dependencyMetadata.getDependencyDescriptor();
            if (dependencyDescriptor instanceof MavenDependencyDescriptor) {
                encoder.writeByte(MAVEN_DEPENDENCY_METADATA);
                writeMavenDependency(encoder, (MavenDependencyDescriptor) dependencyDescriptor, deduplicationDependencyCache);
            } else {
                throw new IllegalStateException("Unknown type of dependency descriptor: " + dependencyDescriptor.getClass());
            }
            encoder.writeNullableString(dependency.getReason());
        }
    }
}
Also used : ForcedDependencyMetadataWrapper(org.gradle.internal.component.external.model.ForcedDependencyMetadataWrapper) GradleDependencyMetadata(org.gradle.internal.component.external.model.GradleDependencyMetadata) ConfigurationBoundExternalDependencyMetadata(org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata) ExternalDependencyDescriptor(org.gradle.internal.component.external.model.ExternalDependencyDescriptor) GradleDependencyMetadata(org.gradle.internal.component.external.model.GradleDependencyMetadata) DependencyMetadata(org.gradle.internal.component.model.DependencyMetadata) ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) ConfigurationBoundExternalDependencyMetadata(org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata)

Example 2 with ExternalDependencyDescriptor

use of org.gradle.internal.component.external.model.ExternalDependencyDescriptor in project gradle by gradle.

the class ModuleComponentResolveMetadataSerializer method write.

@Override
public void write(Encoder encoder, ModuleComponentResolveMetadata value) throws Exception {
    AbstractRealisedModuleComponentResolveMetadata transformed = assertRealized(value);
    HashMap<ExternalDependencyDescriptor, Integer> deduplicationDependencyCache = Maps.newHashMap();
    delegate.write(encoder, transformed, deduplicationDependencyCache);
    writeOwners(encoder, value.getPlatformOwners());
    if (transformed instanceof RealisedIvyModuleResolveMetadata) {
        ivySerializationHelper.writeRealisedVariantsData(encoder, transformed);
        ivySerializationHelper.writeRealisedConfigurationsData(encoder, transformed, deduplicationDependencyCache);
    } else if (transformed instanceof RealisedMavenModuleResolveMetadata) {
        mavenSerializationHelper.writeRealisedVariantsData(encoder, transformed);
        mavenSerializationHelper.writeRealisedConfigurationsData(encoder, transformed, deduplicationDependencyCache);
    } else {
        throw new IllegalStateException("Unexpected realised module component resolve metadata type: " + transformed.getClass());
    }
}
Also used : RealisedIvyModuleResolveMetadata(org.gradle.internal.component.external.model.ivy.RealisedIvyModuleResolveMetadata) ExternalDependencyDescriptor(org.gradle.internal.component.external.model.ExternalDependencyDescriptor) AbstractRealisedModuleComponentResolveMetadata(org.gradle.internal.component.external.model.AbstractRealisedModuleComponentResolveMetadata) RealisedMavenModuleResolveMetadata(org.gradle.internal.component.external.model.maven.RealisedMavenModuleResolveMetadata)

Example 3 with ExternalDependencyDescriptor

use of org.gradle.internal.component.external.model.ExternalDependencyDescriptor in project gradle by gradle.

the class DirectDependencyMetadataAdapter method getIvyArtifacts.

private List<IvyArtifactName> getIvyArtifacts() {
    ModuleDependencyMetadata originalMetadata = getOriginalMetadata();
    if (originalMetadata instanceof ConfigurationBoundExternalDependencyMetadata) {
        ConfigurationBoundExternalDependencyMetadata externalMetadata = (ConfigurationBoundExternalDependencyMetadata) originalMetadata;
        ExternalDependencyDescriptor descriptor = externalMetadata.getDependencyDescriptor();
        if (descriptor instanceof MavenDependencyDescriptor) {
            return fromMavenDescriptor((MavenDependencyDescriptor) descriptor);
        }
        if (descriptor instanceof IvyDependencyDescriptor) {
            return fromIvyDescriptor((IvyDependencyDescriptor) descriptor);
        }
    } else if (originalMetadata instanceof GradleDependencyMetadata) {
        return fromGradleMetadata((GradleDependencyMetadata) originalMetadata);
    }
    return Collections.emptyList();
}
Also used : IvyDependencyDescriptor(org.gradle.internal.component.external.model.ivy.IvyDependencyDescriptor) GradleDependencyMetadata(org.gradle.internal.component.external.model.GradleDependencyMetadata) MavenDependencyDescriptor(org.gradle.internal.component.external.model.maven.MavenDependencyDescriptor) ConfigurationBoundExternalDependencyMetadata(org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata) ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) ExternalDependencyDescriptor(org.gradle.internal.component.external.model.ExternalDependencyDescriptor)

Example 4 with ExternalDependencyDescriptor

use of org.gradle.internal.component.external.model.ExternalDependencyDescriptor in project gradle by gradle.

the class RealisedIvyModuleResolveMetadataSerializationHelper method writeDependencies.

@Override
protected void writeDependencies(Encoder encoder, ConfigurationMetadata configuration, Map<ExternalDependencyDescriptor, Integer> deduplicationDependencyCache) throws IOException {
    List<? extends DependencyMetadata> dependencies = configuration.getDependencies();
    encoder.writeSmallInt(dependencies.size());
    for (DependencyMetadata dependency : dependencies) {
        if (dependency instanceof GradleDependencyMetadata) {
            encoder.writeByte(GRADLE_DEPENDENCY_METADATA);
            writeDependencyMetadata(encoder, (GradleDependencyMetadata) dependency);
        } else if (dependency instanceof ConfigurationBoundExternalDependencyMetadata) {
            ConfigurationBoundExternalDependencyMetadata dependencyMetadata = (ConfigurationBoundExternalDependencyMetadata) dependency;
            ExternalDependencyDescriptor dependencyDescriptor = dependencyMetadata.getDependencyDescriptor();
            if (dependencyDescriptor instanceof IvyDependencyDescriptor) {
                encoder.writeByte(IVY_DEPENDENCY_METADATA);
                boolean addedByRule = configuration instanceof RealisedConfigurationMetadata && ((RealisedConfigurationMetadata) configuration).isAddedByRule();
                writeIvyDependency(encoder, (IvyDependencyDescriptor) dependencyDescriptor, configuration.getName(), addedByRule);
            } else {
                throw new IllegalStateException("Unknown type of dependency descriptor: " + dependencyDescriptor.getClass());
            }
            encoder.writeNullableString(dependency.getReason());
        }
    }
}
Also used : GradleDependencyMetadata(org.gradle.internal.component.external.model.GradleDependencyMetadata) ConfigurationBoundExternalDependencyMetadata(org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata) ExternalDependencyDescriptor(org.gradle.internal.component.external.model.ExternalDependencyDescriptor) GradleDependencyMetadata(org.gradle.internal.component.external.model.GradleDependencyMetadata) DependencyMetadata(org.gradle.internal.component.model.DependencyMetadata) ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) ConfigurationBoundExternalDependencyMetadata(org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata)

Aggregations

ExternalDependencyDescriptor (org.gradle.internal.component.external.model.ExternalDependencyDescriptor)4 ConfigurationBoundExternalDependencyMetadata (org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata)3 GradleDependencyMetadata (org.gradle.internal.component.external.model.GradleDependencyMetadata)3 ModuleDependencyMetadata (org.gradle.internal.component.external.model.ModuleDependencyMetadata)3 DependencyMetadata (org.gradle.internal.component.model.DependencyMetadata)2 AbstractRealisedModuleComponentResolveMetadata (org.gradle.internal.component.external.model.AbstractRealisedModuleComponentResolveMetadata)1 ForcedDependencyMetadataWrapper (org.gradle.internal.component.external.model.ForcedDependencyMetadataWrapper)1 RealisedConfigurationMetadata (org.gradle.internal.component.external.model.RealisedConfigurationMetadata)1 IvyDependencyDescriptor (org.gradle.internal.component.external.model.ivy.IvyDependencyDescriptor)1 RealisedIvyModuleResolveMetadata (org.gradle.internal.component.external.model.ivy.RealisedIvyModuleResolveMetadata)1 MavenDependencyDescriptor (org.gradle.internal.component.external.model.maven.MavenDependencyDescriptor)1 RealisedMavenModuleResolveMetadata (org.gradle.internal.component.external.model.maven.RealisedMavenModuleResolveMetadata)1