Search in sources :

Example 1 with DefaultProjectComponentSelector

use of org.gradle.internal.component.local.model.DefaultProjectComponentSelector in project gradle by gradle.

the class ComponentSelectorSerializer method read.

@Override
public ComponentSelector read(Decoder decoder) throws IOException {
    byte id = decoder.readByte();
    if (Implementation.ROOT_PROJECT.getId() == id) {
        BuildIdentifier buildIdentifier = buildIdentifierSerializer.read(decoder);
        String projectName = decoder.readString();
        return new DefaultProjectComponentSelector(buildIdentifier, Path.ROOT, Path.ROOT, projectName, readAttributes(decoder), readCapabilities(decoder));
    } else if (Implementation.ROOT_BUILD_PROJECT.getId() == id) {
        BuildIdentifier buildIdentifier = buildIdentifierSerializer.read(decoder);
        Path projectPath = Path.path(decoder.readString());
        return new DefaultProjectComponentSelector(buildIdentifier, projectPath, projectPath, projectPath.getName(), readAttributes(decoder), readCapabilities(decoder));
    } else if (Implementation.OTHER_BUILD_ROOT_PROJECT.getId() == id) {
        BuildIdentifier buildIdentifier = buildIdentifierSerializer.read(decoder);
        Path identityPath = Path.path(decoder.readString());
        return new DefaultProjectComponentSelector(buildIdentifier, identityPath, Path.ROOT, identityPath.getName(), readAttributes(decoder), readCapabilities(decoder));
    } else if (Implementation.OTHER_BUILD_PROJECT.getId() == id) {
        BuildIdentifier buildIdentifier = buildIdentifierSerializer.read(decoder);
        Path identityPath = Path.path(decoder.readString());
        Path projectPath = Path.path(decoder.readString());
        return new DefaultProjectComponentSelector(buildIdentifier, identityPath, projectPath, projectPath.getName(), readAttributes(decoder), readCapabilities(decoder));
    } else if (Implementation.MODULE.getId() == id) {
        return DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(decoder.readString(), decoder.readString()), readVersionConstraint(decoder), readAttributes(decoder), readCapabilities(decoder));
    } else if (Implementation.LIBRARY.getId() == id) {
        return new DefaultLibraryComponentSelector(decoder.readString(), decoder.readNullableString(), decoder.readNullableString());
    }
    throw new IllegalArgumentException("Unable to find component selector with id: " + id);
}
Also used : Path(org.gradle.util.Path) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) BuildIdentifier(org.gradle.api.artifacts.component.BuildIdentifier) DefaultLibraryComponentSelector(org.gradle.internal.component.local.model.DefaultLibraryComponentSelector)

Example 2 with DefaultProjectComponentSelector

use of org.gradle.internal.component.local.model.DefaultProjectComponentSelector in project gradle by gradle.

the class ComponentSelectorSerializer method write.

@Override
public void write(Encoder encoder, ComponentSelector value) throws IOException {
    if (value == null) {
        throw new IllegalArgumentException("Provided component selector may not be null");
    }
    Implementation implementation = resolveImplementation(value);
    encoder.writeByte(implementation.getId());
    if (implementation == Implementation.MODULE) {
        ModuleComponentSelector moduleComponentSelector = (ModuleComponentSelector) value;
        encoder.writeString(moduleComponentSelector.getGroup());
        encoder.writeString(moduleComponentSelector.getModule());
        VersionConstraint versionConstraint = moduleComponentSelector.getVersionConstraint();
        writeVersionConstraint(encoder, versionConstraint);
        writeAttributes(encoder, moduleComponentSelector.getAttributes());
        writeCapabilities(encoder, moduleComponentSelector.getRequestedCapabilities());
    } else if (implementation == Implementation.ROOT_PROJECT) {
        DefaultProjectComponentSelector projectComponentSelector = (DefaultProjectComponentSelector) value;
        buildIdentifierSerializer.write(encoder, projectComponentSelector.getBuildIdentifier());
        encoder.writeString(projectComponentSelector.getProjectName());
        writeAttributes(encoder, projectComponentSelector.getAttributes());
        writeCapabilities(encoder, projectComponentSelector.getRequestedCapabilities());
    } else if (implementation == Implementation.ROOT_BUILD_PROJECT) {
        DefaultProjectComponentSelector projectComponentSelector = (DefaultProjectComponentSelector) value;
        buildIdentifierSerializer.write(encoder, projectComponentSelector.getBuildIdentifier());
        encoder.writeString(projectComponentSelector.getProjectPath());
        writeAttributes(encoder, projectComponentSelector.getAttributes());
        writeCapabilities(encoder, projectComponentSelector.getRequestedCapabilities());
    } else if (implementation == Implementation.OTHER_BUILD_ROOT_PROJECT) {
        DefaultProjectComponentSelector projectComponentSelector = (DefaultProjectComponentSelector) value;
        buildIdentifierSerializer.write(encoder, projectComponentSelector.getBuildIdentifier());
        encoder.writeString(projectComponentSelector.getIdentityPath().getPath());
        writeAttributes(encoder, projectComponentSelector.getAttributes());
        writeCapabilities(encoder, projectComponentSelector.getRequestedCapabilities());
    } else if (implementation == Implementation.OTHER_BUILD_PROJECT) {
        DefaultProjectComponentSelector projectComponentSelector = (DefaultProjectComponentSelector) value;
        buildIdentifierSerializer.write(encoder, projectComponentSelector.getBuildIdentifier());
        encoder.writeString(projectComponentSelector.getIdentityPath().getPath());
        encoder.writeString(projectComponentSelector.getProjectPath());
        writeAttributes(encoder, projectComponentSelector.getAttributes());
        writeCapabilities(encoder, projectComponentSelector.getRequestedCapabilities());
    } else if (implementation == Implementation.LIBRARY) {
        LibraryComponentSelector libraryComponentSelector = (LibraryComponentSelector) value;
        encoder.writeString(libraryComponentSelector.getProjectPath());
        encoder.writeNullableString(libraryComponentSelector.getLibraryName());
        encoder.writeNullableString(libraryComponentSelector.getVariant());
    } else {
        throw new IllegalStateException("Unsupported implementation type: " + implementation);
    }
}
Also used : ImmutableVersionConstraint(org.gradle.api.internal.artifacts.ImmutableVersionConstraint) VersionConstraint(org.gradle.api.artifacts.VersionConstraint) DefaultImmutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) LibraryComponentSelector(org.gradle.api.artifacts.component.LibraryComponentSelector) DefaultLibraryComponentSelector(org.gradle.internal.component.local.model.DefaultLibraryComponentSelector)

Example 3 with DefaultProjectComponentSelector

use of org.gradle.internal.component.local.model.DefaultProjectComponentSelector in project gradle by gradle.

the class AttributeDesugaring method desugarSelector.

public ComponentSelector desugarSelector(ComponentSelector selector) {
    if (selector instanceof ModuleComponentSelector) {
        ModuleComponentSelector module = (ModuleComponentSelector) selector;
        AttributeContainer moduleAttributes = module.getAttributes();
        if (!moduleAttributes.isEmpty()) {
            ImmutableAttributes attributes = ((AttributeContainerInternal) moduleAttributes).asImmutable();
            return DefaultModuleComponentSelector.newSelector(module.getModuleIdentifier(), module.getVersionConstraint(), desugar(attributes), module.getRequestedCapabilities());
        }
    }
    if (selector instanceof DefaultProjectComponentSelector) {
        DefaultProjectComponentSelector project = (DefaultProjectComponentSelector) selector;
        AttributeContainer projectAttributes = project.getAttributes();
        if (!projectAttributes.isEmpty()) {
            ImmutableAttributes attributes = ((AttributeContainerInternal) projectAttributes).asImmutable();
            return new DefaultProjectComponentSelector(project.getBuildIdentifier(), project.getIdentityPath(), project.projectPath(), project.getProjectName(), desugar(attributes), project.getRequestedCapabilities());
        }
    }
    return selector;
}
Also used : DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) AttributeContainer(org.gradle.api.attributes.AttributeContainer)

Aggregations

DefaultProjectComponentSelector (org.gradle.internal.component.local.model.DefaultProjectComponentSelector)3 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)2 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)2 DefaultLibraryComponentSelector (org.gradle.internal.component.local.model.DefaultLibraryComponentSelector)2 VersionConstraint (org.gradle.api.artifacts.VersionConstraint)1 BuildIdentifier (org.gradle.api.artifacts.component.BuildIdentifier)1 LibraryComponentSelector (org.gradle.api.artifacts.component.LibraryComponentSelector)1 AttributeContainer (org.gradle.api.attributes.AttributeContainer)1 ImmutableVersionConstraint (org.gradle.api.internal.artifacts.ImmutableVersionConstraint)1 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)1 Path (org.gradle.util.Path)1