use of org.gradle.api.internal.artifacts.repositories.ResolutionAwareRepository in project gradle by gradle.
the class ResolveIvyFactory method create.
public ComponentResolvers create(ResolutionStrategyInternal resolutionStrategy, Collection<? extends ResolutionAwareRepository> repositories, ComponentMetadataProcessor metadataProcessor) {
if (repositories.isEmpty()) {
return new NoRepositoriesResolver();
}
ResolutionRules resolutionRules = resolutionStrategy.getResolutionRules();
CachePolicy cachePolicy = resolutionStrategy.getCachePolicy();
startParameterResolutionOverride.addResolutionRules(resolutionRules);
UserResolverChain moduleResolver = new UserResolverChain(versionSelectorScheme, versionComparator, resolutionStrategy.getComponentSelection(), moduleIdentifierFactory);
ParentModuleLookupResolver parentModuleResolver = new ParentModuleLookupResolver(versionSelectorScheme, versionComparator, moduleIdentifierFactory);
for (ResolutionAwareRepository repository : repositories) {
ConfiguredModuleComponentRepository baseRepository = repository.createResolver();
if (baseRepository instanceof ExternalResourceResolver) {
((ExternalResourceResolver) baseRepository).setComponentResolvers(parentModuleResolver);
}
ModuleComponentRepository moduleComponentRepository = baseRepository;
if (baseRepository.isLocal()) {
moduleComponentRepository = new CachingModuleComponentRepository(moduleComponentRepository, cacheProvider.getInMemoryCaches(), cachePolicy, timeProvider, metadataProcessor, moduleIdentifierFactory);
moduleComponentRepository = new LocalModuleComponentRepository(moduleComponentRepository, metadataProcessor);
} else {
moduleComponentRepository = startParameterResolutionOverride.overrideModuleVersionRepository(moduleComponentRepository);
moduleComponentRepository = new CachingModuleComponentRepository(moduleComponentRepository, cacheProvider.getCaches(), cachePolicy, timeProvider, metadataProcessor, moduleIdentifierFactory);
}
moduleComponentRepository = cacheProvider.getResolvedArtifactCaches().provideResolvedArtifactCache(moduleComponentRepository);
if (baseRepository.isDynamicResolveMode()) {
moduleComponentRepository = new IvyDynamicResolveModuleComponentRepository(moduleComponentRepository);
}
moduleComponentRepository = new ErrorHandlingModuleComponentRepository(moduleComponentRepository, repositoryBlacklister);
moduleResolver.add(moduleComponentRepository);
parentModuleResolver.add(moduleComponentRepository);
}
return moduleResolver;
}
use of org.gradle.api.internal.artifacts.repositories.ResolutionAwareRepository in project gradle by gradle.
the class JvmTestSuiteBasePlugin method configureRuntimeClasspath.
@Finalize
public void configureRuntimeClasspath(@Each JvmTestSuiteBinarySpecInternal testBinary, ServiceRegistry serviceRegistry, ModelSchemaStore modelSchemaStore) {
ArtifactDependencyResolver dependencyResolver = serviceRegistry.get(ArtifactDependencyResolver.class);
RepositoryHandler repositories = serviceRegistry.get(RepositoryHandler.class);
List<ResolutionAwareRepository> resolutionAwareRepositories = CollectionUtils.collect(repositories, Transformers.cast(ResolutionAwareRepository.class));
ModelSchema<? extends JvmTestSuiteBinarySpec> schema = Cast.uncheckedCast(modelSchemaStore.getSchema(((BinarySpecInternal) testBinary).getPublicType()));
AttributesSchemaInternal attributesSchema = serviceRegistry.get(AttributesSchemaInternal.class);
ImmutableModuleIdentifierFactory moduleIdentifierFactory = serviceRegistry.get(ImmutableModuleIdentifierFactory.class);
BuildOperationExecutor buildOperationExecutor = serviceRegistry.get(BuildOperationExecutor.class);
BuildIdentity buildIdentity = serviceRegistry.get(BuildIdentity.class);
testBinary.setRuntimeClasspath(configureRuntimeClasspath(testBinary, dependencyResolver, resolutionAwareRepositories, schema, attributesSchema, moduleIdentifierFactory, buildOperationExecutor, buildIdentity));
}
use of org.gradle.api.internal.artifacts.repositories.ResolutionAwareRepository 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.internal.artifacts.repositories.ResolutionAwareRepository in project gradle by gradle.
the class ResolveIvyFactory method create.
public ComponentResolvers create(String resolveContextName, ResolutionStrategyInternal resolutionStrategy, Collection<? extends ResolutionAwareRepository> repositories, ComponentMetadataProcessorFactory metadataProcessor, AttributeContainer consumerAttributes, AttributesSchema attributesSchema, ImmutableAttributesFactory attributesFactory, ComponentMetadataSupplierRuleExecutor componentMetadataSupplierRuleExecutor) {
if (repositories.isEmpty()) {
return new NoRepositoriesResolver();
}
CachePolicy cachePolicy = resolutionStrategy.getCachePolicy();
startParameterResolutionOverride.applyToCachePolicy(cachePolicy);
UserResolverChain moduleResolver = new UserResolverChain(versionComparator, resolutionStrategy.getComponentSelection(), versionParser, consumerAttributes, attributesSchema, attributesFactory, metadataProcessor, componentMetadataSupplierRuleExecutor, cachePolicy, calculatedValueContainerFactory);
ParentModuleLookupResolver parentModuleResolver = new ParentModuleLookupResolver(versionComparator, moduleIdentifierFactory, versionParser, consumerAttributes, attributesSchema, attributesFactory, metadataProcessor, componentMetadataSupplierRuleExecutor, cachePolicy, calculatedValueContainerFactory);
for (ResolutionAwareRepository repository : repositories) {
ConfiguredModuleComponentRepository baseRepository = repository.createResolver();
baseRepository.setComponentResolvers(parentModuleResolver);
Instantiator instantiator = baseRepository.getComponentMetadataInstantiator();
MetadataResolutionContext metadataResolutionContext = new DefaultMetadataResolutionContext(cachePolicy, instantiator);
ComponentMetadataProcessor componentMetadataProcessor = metadataProcessor.createComponentMetadataProcessor(metadataResolutionContext);
ModuleComponentRepository moduleComponentRepository = baseRepository;
if (baseRepository.isLocal()) {
moduleComponentRepository = new CachingModuleComponentRepository(moduleComponentRepository, cacheProvider.getInMemoryOnlyCaches(), cachePolicy, timeProvider, componentMetadataProcessor, ChangingValueDependencyResolutionListener.NO_OP);
moduleComponentRepository = new LocalModuleComponentRepository(moduleComponentRepository);
} else {
moduleComponentRepository = startParameterResolutionOverride.overrideModuleVersionRepository(moduleComponentRepository);
moduleComponentRepository = new CachingModuleComponentRepository(moduleComponentRepository, cacheProvider.getPersistentCaches(), cachePolicy, timeProvider, componentMetadataProcessor, listener);
}
moduleComponentRepository = cacheProvider.getResolvedArtifactCaches().provideResolvedArtifactCache(moduleComponentRepository, resolutionStrategy.isDependencyVerificationEnabled());
if (baseRepository.isDynamicResolveMode()) {
moduleComponentRepository = new IvyDynamicResolveModuleComponentRepository(moduleComponentRepository);
}
moduleComponentRepository = new ErrorHandlingModuleComponentRepository(moduleComponentRepository, repositoryBlacklister);
moduleComponentRepository = filterRepository(repository, moduleComponentRepository, resolveContextName, consumerAttributes);
moduleComponentRepository = dependencyVerificationOverride.overrideDependencyVerification(moduleComponentRepository, resolveContextName, resolutionStrategy);
moduleResolver.add(moduleComponentRepository);
parentModuleResolver.add(moduleComponentRepository);
}
return moduleResolver;
}
Aggregations