use of org.gradle.internal.resolve.ModuleVersionResolveException in project gradle by gradle.
the class DefaultIncludedBuildTaskGraph method checkNoCycles.
private void checkNoCycles(BuildIdentifier sourceBuild, BuildIdentifier targetBuild, List<BuildIdentifier> candidateCycle) {
candidateCycle.add(targetBuild);
for (BuildIdentifier nextTarget : buildDependencies.get(targetBuild)) {
if (sourceBuild.equals(nextTarget)) {
candidateCycle.add(nextTarget);
ProjectComponentSelector selector = DefaultProjectComponentSelector.newSelector(candidateCycle.get(0), Path.ROOT.getPath());
throw new ModuleVersionResolveException(selector, "Included build dependency cycle: " + reportCycle(candidateCycle));
}
checkNoCycles(sourceBuild, nextTarget, candidateCycle);
}
candidateCycle.remove(targetBuild);
}
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;
}
final Collection<? extends Binary> matchingVariants = chooseMatchingVariants(selectedLibrary, variant);
if (matchingVariants.isEmpty()) {
// no compatible variant found
final Iterable<? extends Binary> values = selectedLibrary.getVariants();
result.failed(new ModuleVersionResolveException(selector, new Factory<String>() {
@Nullable
@Override
public String create() {
return errorMessageBuilder.noCompatibleVariantErrorMessage(libraryName, values);
}
}));
} else if (matchingVariants.size() > 1) {
result.failed(new ModuleVersionResolveException(selector, new Factory<String>() {
@Nullable
@Override
public String create() {
return 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 parameterized
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 DefaultComponentMetadataProcessor method processMetadata.
@Override
public ComponentMetadata processMetadata(ComponentMetadata metadata) {
ComponentMetadata updatedMetadata;
if (metadataRuleContainer.isEmpty()) {
updatedMetadata = metadata;
} else {
ShallowComponentMetadataAdapter details = new ShallowComponentMetadataAdapter(componentIdentifierNotationParser, metadata, attributesFactory);
processAllRules(null, details, metadata.getId());
updatedMetadata = details.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.getId().toString(), updatedMetadata.getStatusScheme()));
}
return updatedMetadata;
}
use of org.gradle.internal.resolve.ModuleVersionResolveException in project gradle by gradle.
the class DefaultComponentMetadataProcessor method processMetadata.
@Override
public ModuleComponentResolveMetadata processMetadata(ModuleComponentResolveMetadata origin) {
VariantDerivationStrategy curStrategy = metadataRuleContainer.getVariantDerivationStrategy();
ModuleComponentResolveMetadata metadata = origin.withDerivationStrategy(curStrategy);
ModuleComponentResolveMetadata updatedMetadata;
if (metadataRuleContainer.isEmpty()) {
updatedMetadata = maybeForceRealisation(metadata);
} else if (metadataRuleContainer.isClassBasedRulesOnly()) {
Action<ComponentMetadataContext> action = collectRulesAndCreateAction(metadataRuleContainer.getOnlyClassRules(), metadata.getModuleVersionId(), metadataResolutionContext.getInjectingInstantiator());
if (action instanceof InstantiatingAction) {
InstantiatingAction<ComponentMetadataContext> ia = (InstantiatingAction<ComponentMetadataContext>) action;
if (shouldCacheComponentMetadataRule(ia, metadata)) {
updatedMetadata = processClassRuleWithCaching(ia, metadata, metadataResolutionContext);
} else {
MutableModuleComponentResolveMetadata mutableMetadata = metadata.asMutable();
processClassRule(action, metadata, createDetails(mutableMetadata));
updatedMetadata = maybeForceRealisation(mutableMetadata.asImmutable());
}
} else {
updatedMetadata = maybeForceRealisation(metadata);
}
} else {
MutableModuleComponentResolveMetadata mutableMetadata = metadata.asMutable();
ComponentMetadataDetails details = createDetails(mutableMetadata);
processAllRules(metadata, details, metadata.getModuleVersionId());
updatedMetadata = maybeForceRealisation(mutableMetadata.asImmutable());
}
if (!updatedMetadata.getStatusScheme().contains(updatedMetadata.getStatus())) {
throw new ModuleVersionResolveException(updatedMetadata.getModuleVersionId(), () -> String.format("Unexpected status '%s' specified for %s. Expected one of: %s", updatedMetadata.getStatus(), updatedMetadata.getId().getDisplayName(), updatedMetadata.getStatusScheme()));
}
return updatedMetadata;
}
use of org.gradle.internal.resolve.ModuleVersionResolveException in project gradle by gradle.
the class DynamicVersionResolver method resolve.
public void resolve(ModuleDependencyMetadata dependency, VersionSelector versionSelector, @Nullable VersionSelector rejectedVersionSelector, AttributeContainer consumerAttributes, BuildableComponentIdResolveResult result) {
ModuleComponentSelector requested = dependency.getSelector();
LOGGER.debug("Attempting to resolve version for {} using repositories {}", requested, repositoryNames);
List<Throwable> errors = new ArrayList<>();
List<RepositoryResolveState> resolveStates = Lists.newArrayListWithCapacity(repositories.size());
for (ModuleComponentRepository repository : repositories) {
resolveStates.add(new RepositoryResolveState(versionedComponentChooser, dependency, repository, versionSelector, rejectedVersionSelector, versionParser, consumerAttributes, attributesFactory, componentMetadataProcessor, componentMetadataSupplierRuleExecutor, cachePolicy));
}
final RepositoryChainModuleResolution latestResolved = findLatestModule(resolveStates, errors);
if (latestResolved != null) {
LOGGER.debug("Using {} from {}", latestResolved.module.getModuleVersionId(), latestResolved.repository);
for (Throwable error : errors) {
LOGGER.debug("Discarding resolve failure.", error);
}
found(result, resolveStates, latestResolved);
return;
}
if (!errors.isEmpty()) {
result.failed(new ModuleVersionResolveException(requested, errors));
} else {
notFound(result, requested, resolveStates);
}
}
Aggregations