use of org.gradle.api.capabilities.Capability in project gradle by gradle.
the class LastCandidateCapabilityResolver method resolve.
@Override
public void resolve(CapabilitiesConflictHandler.ResolutionDetails details) {
Collection<? extends Capability> capabilityVersions = details.getCapabilityVersions();
CapabilitiesConflictHandler.CandidateDetails single = null;
for (Capability capabilityVersion : capabilityVersions) {
Collection<? extends CapabilitiesConflictHandler.CandidateDetails> candidates = details.getCandidates(capabilityVersion);
int size = candidates.size();
if (size >= 1) {
if (size == 1 && single == null) {
single = candidates.iterator().next();
} else {
// not a single candidate
return;
}
}
}
if (single != null) {
single.select();
}
}
use of org.gradle.api.capabilities.Capability in project gradle by gradle.
the class ComponentSelectorSerializer method writeCapabilities.
private void writeCapabilities(Encoder encoder, Collection<Capability> capabilities) throws IOException {
encoder.writeSmallInt(capabilities.size());
for (Capability capability : capabilities) {
encoder.writeString(capability.getGroup());
encoder.writeString(capability.getName());
encoder.writeNullableString(capability.getVersion());
}
}
use of org.gradle.api.capabilities.Capability in project gradle by gradle.
the class ComponentSelectorSerializer method readCapabilities.
private List<Capability> readCapabilities(Decoder decoder) throws IOException {
int size = decoder.readSmallInt();
if (size == 0) {
return Collections.emptyList();
}
ImmutableList.Builder<Capability> builder = ImmutableList.builderWithExpectedSize(size);
for (int i = 0; i < size; i++) {
builder.add(new ImmutableCapability(decoder.readString(), decoder.readString(), decoder.readNullableString()));
}
return builder.build();
}
use of org.gradle.api.capabilities.Capability 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);
}
use of org.gradle.api.capabilities.Capability in project gradle by gradle.
the class AbstractRealisedModuleResolveMetadataSerializationHelper method writeCapabilities.
private void writeCapabilities(Encoder encoder, List<? extends Capability> capabilities) throws IOException {
encoder.writeSmallInt(capabilities.size());
for (Capability capability : capabilities) {
boolean shadowed = capability instanceof ShadowedCapability;
if (shadowed) {
ShadowedCapability shadowedCapability = (ShadowedCapability) capability;
encoder.writeNullableString(shadowedCapability.getAppendix());
capability = shadowedCapability.getShadowedCapability();
} else {
encoder.writeNullableString(null);
}
encoder.writeString(capability.getGroup());
encoder.writeString(capability.getName());
encoder.writeString(capability.getVersion());
}
}
Aggregations