Search in sources :

Example 1 with LocalComponentMetadata

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

the class IncludedBuildDependencyMetadataBuilder method registerProject.

private void registerProject(IncludedBuild build, ProjectInternal project) {
    LocalComponentRegistry localComponentRegistry = project.getServices().get(LocalComponentRegistry.class);
    ProjectComponentIdentifier originalIdentifier = newProjectId(project);
    DefaultLocalComponentMetadata originalComponent = (DefaultLocalComponentMetadata) localComponentRegistry.getComponent(originalIdentifier);
    ProjectComponentIdentifier componentIdentifier = newProjectId(build, project.getPath());
    LocalComponentMetadata compositeComponent = createCompositeCopy(build, componentIdentifier, originalComponent);
    context.register(componentIdentifier, compositeComponent, project.getProjectDir());
    for (LocalComponentArtifactMetadata artifactMetaData : localComponentRegistry.getAdditionalArtifacts(originalIdentifier)) {
        context.registerAdditionalArtifact(componentIdentifier, createCompositeCopy(componentIdentifier, artifactMetaData));
    }
}
Also used : DefaultLocalComponentMetadata(org.gradle.internal.component.local.model.DefaultLocalComponentMetadata) LocalComponentMetadata(org.gradle.internal.component.local.model.LocalComponentMetadata) DefaultLocalComponentMetadata(org.gradle.internal.component.local.model.DefaultLocalComponentMetadata) LocalComponentRegistry(org.gradle.api.internal.artifacts.ivyservice.projectmodule.LocalComponentRegistry) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) LocalComponentArtifactMetadata(org.gradle.internal.component.local.model.LocalComponentArtifactMetadata)

Example 2 with LocalComponentMetadata

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

the class ProjectDependencyResolver method resolve.

@Override
public void resolve(DependencyMetadata dependency, BuildableComponentIdResolveResult result) {
    if (dependency.getSelector() instanceof ProjectComponentSelector) {
        ProjectComponentSelector selector = (ProjectComponentSelector) dependency.getSelector();
        ProjectComponentIdentifier project = componentIdentifierFactory.createProjectComponentIdentifier(selector);
        LocalComponentMetadata componentMetaData = localComponentRegistry.getComponent(project);
        if (componentMetaData == null) {
            result.failed(new ModuleVersionResolveException(selector, project + " not found."));
        } else {
            result.resolved(componentMetaData);
        }
    }
}
Also used : ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) LocalComponentMetadata(org.gradle.internal.component.local.model.LocalComponentMetadata) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Example 3 with LocalComponentMetadata

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

the class LocalLibraryDependencyResolver method resolveLibraryAndChooseBinary.

private void resolveLibraryAndChooseBinary(BuildableComponentIdResolveResult result, LibraryComponentSelector selector) {
    final String selectorProjectPath = selector.getProjectPath();
    final String libraryName = selector.getLibraryName();
    final String variant = selector.getVariant();
    LibraryResolutionResult resolutionResult = doResolve(selectorProjectPath, libraryName);
    VariantComponent selectedLibrary = resolutionResult.getSelectedLibrary();
    if (selectedLibrary == null) {
        String message = resolutionResult.toResolutionErrorMessage(selector);
        ModuleVersionResolveException failure = new ModuleVersionResolveException(selector, new LibraryResolveException(message));
        result.failed(failure);
        return;
    }
    Collection<? extends Binary> matchingVariants = chooseMatchingVariants(selectedLibrary, variant);
    if (matchingVariants.isEmpty()) {
        // no compatible variant found
        Iterable<? extends Binary> values = selectedLibrary.getVariants();
        result.failed(new ModuleVersionResolveException(selector, errorMessageBuilder.noCompatibleVariantErrorMessage(libraryName, values)));
    } else if (matchingVariants.size() > 1) {
        result.failed(new ModuleVersionResolveException(selector, errorMessageBuilder.multipleCompatibleVariantsErrorMessage(libraryName, matchingVariants)));
    } else {
        Binary selectedBinary = matchingVariants.iterator().next();
        // TODO:Cedric This is not quite right. We assume that if we are asking for a specific binary, then we resolve to the assembly instead
        // of the jar, but it should be somehow parametrized
        LocalComponentMetadata metaData;
        if (variant == null) {
            metaData = libraryMetaDataAdapter.createLocalComponentMetaData(selectedBinary, selectorProjectPath, false);
        } else {
            metaData = libraryMetaDataAdapter.createLocalComponentMetaData(selectedBinary, selectorProjectPath, true);
        }
        result.resolved(metaData);
    }
}
Also used : LocalComponentMetadata(org.gradle.internal.component.local.model.LocalComponentMetadata) VariantComponent(org.gradle.platform.base.VariantComponent) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) LibraryResolveException(org.gradle.language.base.internal.resolve.LibraryResolveException) Binary(org.gradle.platform.base.Binary)

Example 4 with LocalComponentMetadata

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

the class ProjectDependencyResolver method resolve.

@Override
public void resolve(ComponentIdentifier identifier, ComponentOverrideMetadata componentOverrideMetadata, BuildableComponentResolveResult result) {
    if (identifier instanceof ProjectComponentIdentifier) {
        ProjectComponentIdentifier projectId = (ProjectComponentIdentifier) identifier;
        LocalComponentMetadata componentMetaData = localComponentRegistry.getComponent(projectId);
        if (componentMetaData == null) {
            result.failed(new ModuleVersionResolveException(DefaultProjectComponentSelector.newSelector(projectId), projectId + " not found."));
        } else {
            result.resolved(componentMetaData);
        }
    }
}
Also used : LocalComponentMetadata(org.gradle.internal.component.local.model.LocalComponentMetadata) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Aggregations

LocalComponentMetadata (org.gradle.internal.component.local.model.LocalComponentMetadata)4 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)3 ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)3 ProjectComponentSelector (org.gradle.api.artifacts.component.ProjectComponentSelector)1 LocalComponentRegistry (org.gradle.api.internal.artifacts.ivyservice.projectmodule.LocalComponentRegistry)1 DefaultLocalComponentMetadata (org.gradle.internal.component.local.model.DefaultLocalComponentMetadata)1 DefaultProjectComponentSelector (org.gradle.internal.component.local.model.DefaultProjectComponentSelector)1 LocalComponentArtifactMetadata (org.gradle.internal.component.local.model.LocalComponentArtifactMetadata)1 LibraryResolveException (org.gradle.language.base.internal.resolve.LibraryResolveException)1 Binary (org.gradle.platform.base.Binary)1 VariantComponent (org.gradle.platform.base.VariantComponent)1