use of org.gradle.internal.component.external.model.ForcedDependencyMetadataWrapper 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());
}
}
}
use of org.gradle.internal.component.external.model.ForcedDependencyMetadataWrapper in project gradle by gradle.
the class RealisedMavenModuleResolveMetadataSerializationHelper method readDependencies.
private ImmutableList<ModuleDependencyMetadata> readDependencies(Decoder decoder, DefaultMavenModuleResolveMetadata metadata, RealisedConfigurationMetadata configurationMetadata, Map<Integer, MavenDependencyDescriptor> deduplicationDependencyCache) throws IOException {
ImmutableList.Builder<ModuleDependencyMetadata> builder = ImmutableList.builder();
int dependenciesCount = decoder.readSmallInt();
if (dependenciesCount == 0) {
return ImmutableList.of();
}
for (int j = 0; j < dependenciesCount; j++) {
byte dependencyType = decoder.readByte();
boolean force = false;
if (dependencyType == FORCED_DEPENDENCY_METADATA) {
force = true;
dependencyType = decoder.readByte();
}
ModuleDependencyMetadata md;
switch(dependencyType) {
case GRADLE_DEPENDENCY_METADATA:
md = readDependencyMetadata(decoder);
break;
case MAVEN_DEPENDENCY_METADATA:
MavenDependencyDescriptor mavenDependencyDescriptor = readMavenDependency(decoder, deduplicationDependencyCache);
ModuleDependencyMetadata dependencyMetadata = RealisedMavenModuleResolveMetadata.contextualize(configurationMetadata, metadata.getId(), mavenDependencyDescriptor);
md = dependencyMetadata.withReason(decoder.readNullableString());
break;
case IVY_DEPENDENCY_METADATA:
throw new IllegalStateException("Unexpected Ivy dependency for Maven module");
default:
throw new IllegalStateException("Unknown dependency type " + dependencyType);
}
if (force) {
md = new ForcedDependencyMetadataWrapper(md);
}
builder.add(md);
}
return builder.build();
}
Aggregations