Search in sources :

Example 1 with MutableComponentVariant

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

the class ModuleMetadataParser method consumeVariant.

private void consumeVariant(JsonReader reader, MutableModuleComponentResolveMetadata metadata) throws IOException {
    reader.beginObject();
    String variantName = null;
    ImmutableAttributes attributes = ImmutableAttributes.EMPTY;
    List<ModuleFile> files = Collections.emptyList();
    List<ModuleDependency> dependencies = Collections.emptyList();
    List<ModuleDependencyConstraint> dependencyConstraints = Collections.emptyList();
    List<VariantCapability> capabilities = Collections.emptyList();
    while (reader.peek() != END_OBJECT) {
        String name = reader.nextName();
        if (name.equals("name")) {
            variantName = reader.nextString();
        } else if (name.equals("attributes")) {
            attributes = consumeAttributes(reader);
        } else if (name.equals("files")) {
            files = consumeFiles(reader);
        } else if (name.equals("dependencies")) {
            dependencies = consumeDependencies(reader);
        } else if (name.equals("dependencyConstraints")) {
            dependencyConstraints = consumeDependencyConstraints(reader);
        } else if (name.equals("capabilities")) {
            capabilities = consumeCapabilities(reader);
        } else if (name.equals("available-at")) {
            // For now just collect this as another dependency
            // TODO - collect this information and merge the metadata from the other module
            dependencies = consumeVariantLocation(reader);
        } else {
            consumeAny(reader);
        }
    }
    reader.endObject();
    MutableComponentVariant variant = metadata.addVariant(variantName, attributes);
    for (ModuleFile file : files) {
        variant.addFile(file.name, file.uri);
    }
    for (ModuleDependency dependency : dependencies) {
        variant.addDependency(dependency.group, dependency.module, dependency.versionConstraint, dependency.excludes, dependency.reason);
    }
    for (ModuleDependencyConstraint dependencyConstraint : dependencyConstraints) {
        variant.addDependencyConstraint(dependencyConstraint.group, dependencyConstraint.module, dependencyConstraint.versionConstraint, dependencyConstraint.reason);
    }
    for (VariantCapability capability : capabilities) {
        variant.addCapability(capability.group, capability.name, capability.version);
    }
}
Also used : ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) MutableComponentVariant(org.gradle.internal.component.external.model.MutableComponentVariant)

Aggregations

ImmutableAttributes (org.gradle.api.internal.attributes.ImmutableAttributes)1 MutableComponentVariant (org.gradle.internal.component.external.model.MutableComponentVariant)1