Search in sources :

Example 1 with LibraryComponentSelector

use of org.gradle.api.artifacts.component.LibraryComponentSelector in project gradle by gradle.

the class LocalLibraryDependencyResolver method resolve.

@Override
public void resolve(DependencyMetadata dependency, final BuildableComponentIdResolveResult result) {
    if (dependency.getSelector() instanceof LibraryComponentSelector) {
        LibraryComponentSelector selector = (LibraryComponentSelector) dependency.getSelector();
        resolveLibraryAndChooseBinary(result, selector);
    }
}
Also used : LibraryComponentSelector(org.gradle.api.artifacts.component.LibraryComponentSelector)

Example 2 with LibraryComponentSelector

use of org.gradle.api.artifacts.component.LibraryComponentSelector in project gradle by gradle.

the class DefaultComponentSelectorConverter method getSelector.

@Override
public ModuleVersionSelector getSelector(ComponentSelector selector) {
    if (selector instanceof ModuleComponentSelector) {
        return DefaultModuleVersionSelector.newSelector((ModuleComponentSelector) selector);
    }
    if (selector instanceof ProjectComponentSelector) {
        ProjectComponentSelector projectSelector = (ProjectComponentSelector) selector;
        ProjectComponentIdentifier projectId = componentIdentifierFactory.createProjectComponentIdentifier(projectSelector);
        LocalComponentMetadata projectComponent = localComponentRegistry.getComponent(projectId);
        if (projectComponent != null) {
            ModuleVersionIdentifier moduleVersionId = projectComponent.getModuleVersionId();
            return DefaultModuleVersionSelector.newSelector(moduleVersionId.getModule(), moduleVersionId.getVersion());
        }
    }
    if (selector instanceof LibraryComponentSelector) {
        LibraryComponentSelector libraryComponentSelector = (LibraryComponentSelector) selector;
        String libraryName = GUtil.elvis(libraryComponentSelector.getLibraryName(), "");
        return DefaultModuleVersionSelector.newSelector(DefaultModuleIdentifier.newId(libraryComponentSelector.getProjectPath(), libraryName), "undefined");
    }
    return UNKNOWN_MODULE_VERSION_SELECTOR;
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector) LocalComponentMetadata(org.gradle.internal.component.local.model.LocalComponentMetadata) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) LibraryComponentSelector(org.gradle.api.artifacts.component.LibraryComponentSelector)

Example 3 with LibraryComponentSelector

use of org.gradle.api.artifacts.component.LibraryComponentSelector in project gradle by gradle.

the class LocalLibraryDependencyResolver method resolve.

@Override
public void resolve(DependencyMetadata dependency, ResolvedVersionConstraint versionConstraint, final BuildableComponentIdResolveResult result) {
    if (dependency.getSelector() instanceof LibraryComponentSelector) {
        LibraryComponentSelector selector = (LibraryComponentSelector) dependency.getSelector();
        resolveLibraryAndChooseBinary(result, selector);
    }
}
Also used : LibraryComponentSelector(org.gradle.api.artifacts.component.LibraryComponentSelector)

Example 4 with LibraryComponentSelector

use of org.gradle.api.artifacts.component.LibraryComponentSelector in project gradle by gradle.

the class LocalLibraryDependencyResolver method resolve.

@Override
public void resolve(DependencyMetadata dependency, VersionSelector acceptor, VersionSelector rejector, BuildableComponentIdResolveResult result) {
    if (dependency.getSelector() instanceof LibraryComponentSelector) {
        LibraryComponentSelector selector = (LibraryComponentSelector) dependency.getSelector();
        resolveLibraryAndChooseBinary(result, selector);
    }
}
Also used : LibraryComponentSelector(org.gradle.api.artifacts.component.LibraryComponentSelector)

Example 5 with LibraryComponentSelector

use of org.gradle.api.artifacts.component.LibraryComponentSelector 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)

Aggregations

LibraryComponentSelector (org.gradle.api.artifacts.component.LibraryComponentSelector)5 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)2 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)1 VersionConstraint (org.gradle.api.artifacts.VersionConstraint)1 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)1 ProjectComponentSelector (org.gradle.api.artifacts.component.ProjectComponentSelector)1 ImmutableVersionConstraint (org.gradle.api.internal.artifacts.ImmutableVersionConstraint)1 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)1 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)1 DefaultLibraryComponentSelector (org.gradle.internal.component.local.model.DefaultLibraryComponentSelector)1 DefaultProjectComponentSelector (org.gradle.internal.component.local.model.DefaultProjectComponentSelector)1 LocalComponentMetadata (org.gradle.internal.component.local.model.LocalComponentMetadata)1