use of org.gradle.api.artifacts.UnresolvedDependency in project gradle by gradle.
the class ResolutionFailureCollector method complete.
public Set<UnresolvedDependency> complete() {
if (failuresByRevisionId.isEmpty()) {
ImmutableSet.of();
}
ImmutableSet.Builder<UnresolvedDependency> builder = ImmutableSet.builder();
for (Map.Entry<ComponentSelector, BrokenDependency> entry : failuresByRevisionId.entrySet()) {
Collection<List<ComponentIdentifier>> paths = DependencyGraphPathResolver.calculatePaths(entry.getValue().requiredBy, root);
ComponentSelector key = entry.getKey();
ModuleVersionSelector moduleVersionSelector = componentSelectorConverter.getSelector(key);
builder.add(new DefaultUnresolvedDependency(moduleVersionSelector, entry.getValue().failure.withIncomingPaths(paths)));
}
return builder.build();
}
use of org.gradle.api.artifacts.UnresolvedDependency in project gradle by gradle.
the class ResolutionFailureCollector method complete.
public Set<UnresolvedDependency> complete(Set<UnresolvedDependency> extraFailures) {
if (extraFailures.isEmpty() && failuresByRevisionId.isEmpty()) {
return ImmutableSet.of();
}
ImmutableSet.Builder<UnresolvedDependency> builder = ImmutableSet.builder();
builder.addAll(extraFailures);
for (Map.Entry<ComponentSelector, BrokenDependency> entry : failuresByRevisionId.entrySet()) {
Collection<List<ComponentIdentifier>> paths = DependencyGraphPathResolver.calculatePaths(entry.getValue().requiredBy, root);
ComponentSelector key = entry.getKey();
ModuleVersionSelector moduleVersionSelector = componentSelectorConverter.getSelector(key);
builder.add(new DefaultUnresolvedDependency(moduleVersionSelector, entry.getValue().failure.withIncomingPaths(paths)));
}
return builder.build();
}
use of org.gradle.api.artifacts.UnresolvedDependency in project gradle by gradle.
the class DefaultLenientConfiguration method select.
@Override
public SelectedArtifactSet select(final Spec<? super Dependency> dependencySpec, final AttributeContainerInternal requestedAttributes, final Spec<? super ComponentIdentifier> componentSpec, boolean allowNoMatchingVariants) {
VariantSelector selector = artifactTransforms.variantSelector(requestedAttributes, allowNoMatchingVariants, configuration.getDependenciesResolver());
SelectedArtifactResults artifactResults = this.artifactResults.select(componentSpec, selector);
return new SelectedArtifactSet() {
@Override
public void visitDependencies(TaskDependencyResolveContext context) {
for (UnresolvedDependency unresolvedDependency : unresolvedDependencies) {
context.visitFailure(unresolvedDependency.getProblem());
}
context.add(artifactResults.getArtifacts());
}
@Override
public void visitArtifacts(ArtifactVisitor visitor, boolean continueOnSelectionFailure) {
if (!unresolvedDependencies.isEmpty()) {
for (UnresolvedDependency unresolvedDependency : unresolvedDependencies) {
visitor.visitFailure(unresolvedDependency.getProblem());
}
if (!continueOnSelectionFailure) {
return;
}
}
DefaultLenientConfiguration.this.visitArtifactsWithBuildOperation(dependencySpec, artifactResults, DefaultLenientConfiguration.this.fileDependencyResults, visitor);
}
};
}
use of org.gradle.api.artifacts.UnresolvedDependency in project gradle by gradle.
the class DependencyLockingArtifactVisitor method createLockingFailures.
private static Set<UnresolvedDependency> createLockingFailures(Map<ModuleIdentifier, ModuleComponentIdentifier> modulesToBeLocked, Set<ModuleComponentIdentifier> extraModules, Map<ModuleComponentIdentifier, String> forcedModules) {
Set<UnresolvedDependency> completedFailures = Sets.newHashSetWithExpectedSize(modulesToBeLocked.values().size() + extraModules.size());
for (ModuleComponentIdentifier presentInLock : modulesToBeLocked.values()) {
completedFailures.add(new DefaultUnresolvedDependency(DefaultModuleVersionSelector.newSelector(presentInLock.getModuleIdentifier(), presentInLock.getVersion()), new LockOutOfDateException("Did not resolve '" + presentInLock.getDisplayName() + "' which is part of the dependency lock state")));
}
for (ModuleComponentIdentifier extraModule : extraModules) {
completedFailures.add(new DefaultUnresolvedDependency(DefaultModuleVersionSelector.newSelector(extraModule.getModuleIdentifier(), extraModule.getVersion()), new LockOutOfDateException("Resolved '" + extraModule.getDisplayName() + "' which is not part of the dependency lock state")));
}
for (Map.Entry<ModuleComponentIdentifier, String> entry : forcedModules.entrySet()) {
ModuleComponentIdentifier forcedModule = entry.getKey();
completedFailures.add(new DefaultUnresolvedDependency(DefaultModuleVersionSelector.newSelector(forcedModule.getModuleIdentifier(), forcedModule.getVersion()), new LockOutOfDateException("Did not resolve '" + forcedModule.getDisplayName() + "' which has been forced / substituted to a different version: '" + entry.getValue() + "'")));
}
return completedFailures;
}
use of org.gradle.api.artifacts.UnresolvedDependency in project atlas by alibaba.
the class TDependencyManager method collectArtifacts.
/**
* Collects the resolved artifacts and returns a configuration which contains them. If the
* configuration has unresolved dependencies we check that we have the latest version of the
* Google repository and the Android Support repository and we install them if not. After this,
* the resolution is retried with a fresh copy of the configuration, that will contain the newly
* updated repositories. If this passes, we return the correct configuration and we fill the
* artifacts map.
*
* @param configuration the configuration from which we get the artifacts
* @param artifacts the map of artifacts that are being collected
* @return a valid configuration that has only resolved dependencies.
*/
private Configuration collectArtifacts(Configuration configuration, Map<ModuleVersionIdentifier, List<ResolvedArtifact>> artifacts) {
Set<ResolvedArtifact> allArtifacts;
// Make a copy because Gradle keeps a per configuration state of resolution that we
// need to reset.
Configuration configurationCopy = configuration.copyRecursive();
Set<UnresolvedDependency> unresolvedDependencies = configuration.getResolvedConfiguration().getLenientConfiguration().getUnresolvedModuleDependencies();
if (unresolvedDependencies.isEmpty()) {
allArtifacts = configuration.getResolvedConfiguration().getResolvedArtifacts();
} else {
if (!repositoriesUpdated && sdkLibData.useSdkDownload()) {
List<String> repositoryPaths = new ArrayList<>();
for (UnresolvedDependency dependency : unresolvedDependencies) {
if (isGoogleOwnedDependency(dependency.getSelector())) {
repositoryPaths.add(getRepositoryPath(dependency.getSelector()));
}
}
sdkLibData.setNeedsCacheReset(sdkHandler.checkResetCache());
List<File> updatedRepositories = sdkHandler.getSdkLoader().updateRepositories(repositoryPaths, sdkLibData, logger);
// resolution result.
for (File updatedRepository : updatedRepositories) {
project.getRepositories().maven(newRepo -> {
newRepo.setName("Updated " + updatedRepository.getPath());
newRepo.setUrl(updatedRepository.toURI());
newRepo.artifactUrls(project.getRootProject().file("sdk-manager"));
});
}
repositoriesUpdated = true;
}
if (extraModelInfo.getMode() != STANDARD) {
allArtifacts = configurationCopy.getResolvedConfiguration().getLenientConfiguration().getArtifacts(Specs.satisfyAll());
} else {
allArtifacts = configurationCopy.getResolvedConfiguration().getResolvedArtifacts();
}
// Modify the configuration to the one that passed.
configuration = configurationCopy;
}
for (ResolvedArtifact artifact : allArtifacts) {
ModuleVersionIdentifier id = artifact.getModuleVersion().getId();
List<ResolvedArtifact> moduleArtifacts = artifacts.get(id);
if (moduleArtifacts == null) {
moduleArtifacts = Lists.newArrayList();
artifacts.put(id, moduleArtifacts);
}
if (!moduleArtifacts.contains(artifact)) {
moduleArtifacts.add(artifact);
}
}
return configuration;
}
Aggregations