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));
}
}
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);
}
}
}
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);
}
}
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);
}
}
}
Aggregations