use of org.gradle.api.artifacts.UnresolvedDependency in project gradle by gradle.
the class DefaultConfigurationResolver method resolveGraph.
@Override
public void resolveGraph(ConfigurationInternal configuration, ResolverResults results) {
List<ResolutionAwareRepository> resolutionAwareRepositories = getRepositories();
StoreSet stores = storeFactory.createStoreSet();
BinaryStore oldModelStore = stores.nextBinaryStore();
Store<TransientConfigurationResults> oldModelCache = stores.oldModelCache();
TransientConfigurationResultsBuilder oldTransientModelBuilder = new TransientConfigurationResultsBuilder(oldModelStore, oldModelCache, moduleIdentifierFactory, buildOperationExecutor);
DefaultResolvedConfigurationBuilder oldModelBuilder = new DefaultResolvedConfigurationBuilder(oldTransientModelBuilder);
ResolvedConfigurationDependencyGraphVisitor oldModelVisitor = new ResolvedConfigurationDependencyGraphVisitor(oldModelBuilder);
BinaryStore newModelStore = stores.nextBinaryStore();
Store<ResolvedComponentResult> newModelCache = stores.newModelCache();
StreamingResolutionResultBuilder newModelBuilder = new StreamingResolutionResultBuilder(newModelStore, newModelCache, moduleIdentifierFactory, attributeContainerSerializer, attributeDesugaring, componentSelectionDescriptorFactory);
ResolvedLocalComponentsResultGraphVisitor localComponentsVisitor = new ResolvedLocalComponentsResultGraphVisitor(currentBuild);
ResolutionStrategyInternal resolutionStrategy = configuration.getResolutionStrategy();
DefaultResolvedArtifactsBuilder artifactsBuilder = new DefaultResolvedArtifactsBuilder(buildProjectDependencies, resolutionStrategy.getSortOrder());
FileDependencyCollectingGraphVisitor fileDependencyVisitor = new FileDependencyCollectingGraphVisitor();
ResolutionFailureCollector failureCollector = new ResolutionFailureCollector(componentSelectorConverter);
DependencyGraphVisitor graphVisitor = new CompositeDependencyGraphVisitor(newModelBuilder, localComponentsVisitor, failureCollector);
ImmutableList.Builder<DependencyArtifactsVisitor> visitors = new ImmutableList.Builder<>();
visitors.add(oldModelVisitor);
visitors.add(fileDependencyVisitor);
visitors.add(artifactsBuilder);
if (resolutionStrategy.getConflictResolution() == ConflictResolution.strict) {
ProjectComponentIdentifier projectId = configuration.getModule().getProjectId();
// projectId is null for DefaultModule used in settings
String projectPath = projectId != null ? projectId.getProjectPath() : "";
visitors.add(new FailOnVersionConflictArtifactsVisitor(projectPath, configuration.getName()));
}
DependencyLockingArtifactVisitor lockingVisitor = null;
if (resolutionStrategy.isDependencyLockingEnabled()) {
lockingVisitor = new DependencyLockingArtifactVisitor(configuration.getName(), resolutionStrategy.getDependencyLockingProvider());
visitors.add(lockingVisitor);
} else {
resolutionStrategy.confirmUnlockedConfigurationResolved(configuration.getName());
}
ImmutableList<DependencyArtifactsVisitor> allVisitors = visitors.build();
CompositeDependencyArtifactsVisitor artifactsVisitor = new CompositeDependencyArtifactsVisitor(allVisitors);
resolver.resolve(configuration, resolutionAwareRepositories, metadataHandler, Specs.satisfyAll(), graphVisitor, artifactsVisitor, attributesSchema, artifactTypeRegistry, true);
VisitedArtifactsResults artifactsResults = artifactsBuilder.complete();
VisitedFileDependencyResults fileDependencyResults = fileDependencyVisitor.complete();
ResolvedGraphResults graphResults = oldModelBuilder.complete();
// Append to failures for locking and fail on version conflict
Set<UnresolvedDependency> extraFailures = lockingVisitor == null ? Collections.emptySet() : lockingVisitor.collectLockingFailures();
Set<UnresolvedDependency> failures = failureCollector.complete(extraFailures);
results.graphResolved(newModelBuilder.complete(extraFailures), localComponentsVisitor, new BuildDependenciesOnlyVisitedArtifactSet(failures, artifactsResults, artifactTransforms, configuration.getDependenciesResolver()));
results.retainState(new ArtifactResolveState(graphResults, artifactsResults, fileDependencyResults, failures, oldTransientModelBuilder));
if (!results.hasError() && failures.isEmpty()) {
artifactsVisitor.complete();
}
}
use of org.gradle.api.artifacts.UnresolvedDependency in project gradle by gradle.
the class DefaultResolutionResultBuilder method addExtraFailures.
public void addExtraFailures(Long rootId, Set<UnresolvedDependency> extraFailures) {
DefaultResolvedComponentResult root = modules.get(rootId);
for (UnresolvedDependency failure : extraFailures) {
ModuleVersionSelector failureSelector = failure.getSelector();
ModuleComponentSelector failureComponentSelector = DefaultModuleComponentSelector.newSelector(failureSelector.getModule(), failureSelector.getVersion());
root.addDependency(dependencyResultFactory.createUnresolvedDependency(failureComponentSelector, root, true, ComponentSelectionReasons.of(DEPENDENCY_LOCKING), new ModuleVersionResolveException(failureComponentSelector, () -> "Dependency lock state out of date", failure.getProblem())));
}
}
Aggregations