use of org.gradle.api.internal.attributes.ImmutableAttributes in project gradle by gradle.
the class ModuleComponentSelectorSerializer method read.
@Override
public ModuleComponentSelector read(Decoder decoder) throws IOException {
String group = decoder.readString();
String name = decoder.readString();
VersionConstraint versionConstraint = readVersionConstraint(decoder);
ImmutableAttributes attributes = readAttributes(decoder);
List<Capability> capabilities = readCapabilities(decoder);
return newSelector(DefaultModuleIdentifier.newId(group, name), versionConstraint, attributes, capabilities);
}
use of org.gradle.api.internal.attributes.ImmutableAttributes in project gradle by gradle.
the class GradleModuleMetadataParser method consumeAttributes.
private ImmutableAttributes consumeAttributes(JsonReader reader) throws IOException {
ImmutableAttributes attributes = ImmutableAttributes.EMPTY;
reader.beginObject();
while (reader.peek() != END_OBJECT) {
String attrName = reader.nextName();
if (reader.peek() == BOOLEAN) {
boolean attrValue = reader.nextBoolean();
attributes = attributesFactory.concat(attributes, Attribute.of(attrName, Boolean.class), attrValue);
} else if (reader.peek() == NUMBER) {
Integer attrValue = reader.nextInt();
attributes = attributesFactory.concat(attributes, Attribute.of(attrName, Integer.class), attrValue);
} else {
String attrValue = reader.nextString();
attributes = attributesFactory.concat(attributes, Attribute.of(attrName, String.class), new CoercingStringValueSnapshot(attrValue, instantiator));
}
}
reader.endObject();
return attributes;
}
use of org.gradle.api.internal.attributes.ImmutableAttributes in project gradle by gradle.
the class GradleModuleMetadataParser method consumeDependencyConstraints.
private List<ModuleDependencyConstraint> consumeDependencyConstraints(JsonReader reader) throws IOException {
List<ModuleDependencyConstraint> dependencies = new ArrayList<>();
reader.beginArray();
while (reader.peek() != END_ARRAY) {
String group = null;
String module = null;
String reason = null;
VersionConstraint version = null;
ImmutableAttributes attributes = ImmutableAttributes.EMPTY;
reader.beginObject();
while (reader.peek() != END_OBJECT) {
String name = reader.nextName();
switch(name) {
case "group":
group = reader.nextString();
break;
case "module":
module = reader.nextString();
break;
case "version":
version = consumeVersion(reader);
break;
case "reason":
reason = reader.nextString();
break;
case "attributes":
attributes = consumeAttributes(reader);
break;
default:
consumeAny(reader);
break;
}
}
assertDefined(reader, "group", group);
assertDefined(reader, "module", module);
reader.endObject();
dependencies.add(new ModuleDependencyConstraint(group, module, version, reason, attributes));
}
reader.endArray();
return dependencies;
}
use of org.gradle.api.internal.attributes.ImmutableAttributes in project gradle by gradle.
the class GradleModuleMetadataParser method consumeDependencies.
private List<ModuleDependency> consumeDependencies(JsonReader reader) throws IOException {
List<ModuleDependency> dependencies = new ArrayList<>();
reader.beginArray();
while (reader.peek() != END_ARRAY) {
String group = null;
String module = null;
String reason = null;
ImmutableAttributes attributes = ImmutableAttributes.EMPTY;
VersionConstraint version = DefaultImmutableVersionConstraint.of();
ImmutableList<ExcludeMetadata> excludes = ImmutableList.of();
List<VariantCapability> requestedCapabilities = ImmutableList.of();
IvyArtifactName artifactSelector = null;
boolean endorseStrictVersions = false;
reader.beginObject();
while (reader.peek() != END_OBJECT) {
String name = reader.nextName();
switch(name) {
case "group":
group = reader.nextString();
break;
case "module":
module = reader.nextString();
break;
case "version":
version = consumeVersion(reader);
break;
case "excludes":
excludes = consumeExcludes(reader);
break;
case "reason":
reason = reader.nextString();
break;
case "attributes":
attributes = consumeAttributes(reader);
break;
case "requestedCapabilities":
requestedCapabilities = consumeCapabilities(reader, false);
break;
case "endorseStrictVersions":
endorseStrictVersions = reader.nextBoolean();
break;
case "thirdPartyCompatibility":
reader.beginObject();
while (reader.peek() != END_OBJECT) {
String compatibilityFeatureName = reader.nextName();
if (compatibilityFeatureName.equals("artifactSelector")) {
artifactSelector = consumeArtifactSelector(reader);
} else {
consumeAny(reader);
}
}
reader.endObject();
break;
default:
consumeAny(reader);
break;
}
}
assertDefined(reader, "group", group);
assertDefined(reader, "module", module);
reader.endObject();
dependencies.add(new ModuleDependency(group, module, version, excludes, reason, attributes, requestedCapabilities, endorseStrictVersions, artifactSelector));
}
reader.endArray();
return dependencies;
}
use of org.gradle.api.internal.attributes.ImmutableAttributes in project gradle by gradle.
the class ProjectArtifactSetResolver method mapVariant.
private ResolvedVariant mapVariant(ModuleVersionIdentifier ownerId, ModuleSources moduleSources, ExcludeSpec exclusions, ArtifactTypeRegistry artifactTypeRegistry, VariantResolveMetadata variant) {
VariantResolveMetadata.Identifier identifier = variant.getIdentifier();
if (identifier == null) {
throw new IllegalArgumentException(String.format("Project variant %s does not have an identifier.", variant.asDescribable()));
}
// Apply any artifact type mappings to the attributes of the variant
ImmutableAttributes variantAttributes = artifactTypeRegistry.mapAttributesFor(variant.getAttributes().asImmutable(), variant.getArtifacts());
if (exclusions.mayExcludeArtifacts()) {
// Some artifact may be excluded, so do not reuse. It might be better to apply the exclusions and reuse if none of them apply
return DefaultArtifactSet.toResolvedVariant(variant, ownerId, moduleSources, exclusions, artifactResolver, allProjectArtifacts, variantAttributes, calculatedValueContainerFactory);
}
VariantWithOverloadAttributes key = new VariantWithOverloadAttributes(identifier, variantAttributes);
return allProjectVariants.computeIfAbsent(key, k -> DefaultArtifactSet.toResolvedVariant(variant, ownerId, moduleSources, exclusions, artifactResolver, allProjectArtifacts, variantAttributes, calculatedValueContainerFactory));
}
Aggregations