use of org.gradle.internal.resolve.ModuleVersionResolveException in project gradle by gradle.
the class CompositeBuildDependencySubstitutions method getReplacementFor.
private ProjectComponentIdentifier getReplacementFor(ModuleComponentSelector selector) {
ModuleIdentifier candidateId = moduleIdentifierFactory.module(selector.getGroup(), selector.getModule());
Collection<ProjectComponentIdentifier> providingProjects = replacementMap.get(candidateId);
if (providingProjects.isEmpty()) {
LOGGER.info("Found no composite build substitute for module '" + candidateId + "'.");
return null;
}
if (providingProjects.size() == 1) {
ProjectComponentIdentifier match = providingProjects.iterator().next();
LOGGER.info("Found project '" + match + "' as substitute for module '" + candidateId + "'.");
return match;
}
SortedSet<String> sortedProjects = Sets.newTreeSet(CollectionUtils.collect(providingProjects, new Transformer<String, ProjectComponentIdentifier>() {
@Override
public String transform(ProjectComponentIdentifier projectComponentIdentifier) {
return projectComponentIdentifier.getDisplayName();
}
}));
String failureMessage = String.format("Module version '%s' is not unique in composite: can be provided by %s.", selector.getDisplayName(), sortedProjects);
throw new ModuleVersionResolveException(selector, failureMessage);
}
use of org.gradle.internal.resolve.ModuleVersionResolveException 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.resolve.ModuleVersionResolveException in project gradle by gradle.
the class DefaultComponentMetadataHandler method processMetadata.
public ModuleComponentResolveMetadata processMetadata(ModuleComponentResolveMetadata metadata) {
ModuleComponentResolveMetadata updatedMetadata;
if (rules.isEmpty()) {
updatedMetadata = metadata;
} else {
MutableModuleComponentResolveMetadata mutableMetadata = metadata.asMutable();
ComponentMetadataDetails details = instantiator.newInstance(ComponentMetadataDetailsAdapter.class, mutableMetadata);
processAllRules(metadata, details);
updatedMetadata = mutableMetadata.asImmutable();
}
if (!updatedMetadata.getStatusScheme().contains(updatedMetadata.getStatus())) {
throw new ModuleVersionResolveException(updatedMetadata.getId(), String.format("Unexpected status '%s' specified for %s. Expected one of: %s", updatedMetadata.getStatus(), updatedMetadata.getComponentId().getDisplayName(), updatedMetadata.getStatusScheme()));
}
return updatedMetadata;
}
use of org.gradle.internal.resolve.ModuleVersionResolveException 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);
}
}
}
use of org.gradle.internal.resolve.ModuleVersionResolveException in project gradle by gradle.
the class DependencyResultSerializer method read.
public DependencyResult read(Decoder decoder, Map<Long, ComponentSelector> selectors, Map<ComponentSelector, ModuleVersionResolveException> failures) throws IOException {
Long selectorId = decoder.readSmallLong();
ComponentSelector requested = selectors.get(selectorId);
byte resultByte = decoder.readByte();
if (resultByte == SUCCESSFUL) {
Long selectedId = decoder.readSmallLong();
return new DefaultDependencyResult(requested, selectedId, null, null);
} else if (resultByte == FAILED) {
ComponentSelectionReason reason = componentSelectionReasonSerializer.read(decoder);
ModuleVersionResolveException failure = failures.get(requested);
return new DefaultDependencyResult(requested, null, reason, failure);
} else {
throw new IllegalArgumentException("Unknown result type: " + resultByte);
}
}
Aggregations