use of org.gradle.api.internal.filestore.ArtifactIdentifierFileStore in project gradle by gradle.
the class DependencyManagementBuildScopeServices method createModuleRepositoryCacheProvider.
ModuleRepositoryCacheProvider createModuleRepositoryCacheProvider(BuildCommencedTimeProvider timeProvider, ImmutableModuleIdentifierFactory moduleIdentifierFactory, ArtifactCachesProvider artifactCaches, AttributeContainerSerializer attributeContainerSerializer, MavenMutableModuleMetadataFactory mavenMetadataFactory, IvyMutableModuleMetadataFactory ivyMetadataFactory, SimpleMapInterner stringInterner, FileStoreAndIndexProvider fileStoreAndIndexProvider, ModuleSourcesSerializer moduleSourcesSerializer, ChecksumService checksumService) {
ArtifactIdentifierFileStore artifactIdentifierFileStore = fileStoreAndIndexProvider.getArtifactIdentifierFileStore();
ModuleRepositoryCaches writableCaches = artifactCaches.withWritableCache((md, manager) -> prepareModuleRepositoryCaches(md, manager, timeProvider, moduleIdentifierFactory, attributeContainerSerializer, mavenMetadataFactory, ivyMetadataFactory, stringInterner, artifactIdentifierFileStore, moduleSourcesSerializer, checksumService));
AtomicReference<Path> roCachePath = new AtomicReference<>();
Optional<ModuleRepositoryCaches> readOnlyCaches = artifactCaches.withReadOnlyCache((ro, manager) -> {
roCachePath.set(ro.getCacheDir().toPath());
return prepareReadOnlyModuleRepositoryCaches(ro, manager, timeProvider, moduleIdentifierFactory, attributeContainerSerializer, mavenMetadataFactory, ivyMetadataFactory, stringInterner, artifactIdentifierFileStore, moduleSourcesSerializer, checksumService);
});
AbstractModuleVersionsCache moduleVersionsCache = readOnlyCaches.map(mrc -> (AbstractModuleVersionsCache) new TwoStageModuleVersionsCache(timeProvider, mrc.moduleVersionsCache, writableCaches.moduleVersionsCache)).orElse(writableCaches.moduleVersionsCache);
AbstractModuleMetadataCache persistentModuleMetadataCache = readOnlyCaches.map(mrc -> (AbstractModuleMetadataCache) new TwoStageModuleMetadataCache(timeProvider, mrc.moduleMetadataCache, writableCaches.moduleMetadataCache)).orElse(writableCaches.moduleMetadataCache);
AbstractArtifactsCache moduleArtifactsCache = readOnlyCaches.map(mrc -> (AbstractArtifactsCache) new TwoStageArtifactsCache(timeProvider, mrc.moduleArtifactsCache, writableCaches.moduleArtifactsCache)).orElse(writableCaches.moduleArtifactsCache);
ModuleArtifactCache moduleArtifactCache = readOnlyCaches.map(mrc -> (ModuleArtifactCache) new TwoStageModuleArtifactCache(roCachePath.get(), mrc.moduleArtifactCache, writableCaches.moduleArtifactCache)).orElse(writableCaches.moduleArtifactCache);
ModuleRepositoryCaches persistentCaches = new ModuleRepositoryCaches(new InMemoryModuleVersionsCache(timeProvider, moduleVersionsCache), new InMemoryModuleMetadataCache(timeProvider, persistentModuleMetadataCache), new InMemoryModuleArtifactsCache(timeProvider, moduleArtifactsCache), new InMemoryModuleArtifactCache(timeProvider, moduleArtifactCache));
ModuleRepositoryCaches inMemoryOnlyCaches = new ModuleRepositoryCaches(new InMemoryModuleVersionsCache(timeProvider), new InMemoryModuleMetadataCache(timeProvider), new InMemoryModuleArtifactsCache(timeProvider), new InMemoryModuleArtifactCache(timeProvider));
return new ModuleRepositoryCacheProvider(persistentCaches, inMemoryOnlyCaches);
}
use of org.gradle.api.internal.filestore.ArtifactIdentifierFileStore in project gradle by gradle.
the class DependencyManagementBuildScopeServices method createFileStoreAndIndexProvider.
FileStoreAndIndexProvider createFileStoreAndIndexProvider(BuildCommencedTimeProvider timeProvider, ArtifactCachesProvider artifactCaches, DefaultExternalResourceFileStore.Factory defaultExternalResourceFileStoreFactory, DefaultArtifactIdentifierFileStore.Factory defaultArtifactIdentifierFileStoreFactory) {
ExternalResourceFileStore writableFileStore = defaultExternalResourceFileStoreFactory.create(artifactCaches.getWritableCacheMetadata());
ExternalResourceFileStore externalResourceFileStore = artifactCaches.withReadOnlyCache((md, manager) -> (ExternalResourceFileStore) new TwoStageExternalResourceFileStore(defaultExternalResourceFileStoreFactory.create(md), writableFileStore)).orElse(writableFileStore);
CachedExternalResourceIndex<String> writableByUrlCachedExternalResourceIndex = prepareArtifactUrlCachedResolutionIndex(timeProvider, artifactCaches.getWritableCacheLockingManager(), externalResourceFileStore, artifactCaches.getWritableCacheMetadata());
ArtifactIdentifierFileStore writableArtifactIdentifierFileStore = artifactCaches.withWritableCache((md, manager) -> defaultArtifactIdentifierFileStoreFactory.create(md));
ArtifactIdentifierFileStore artifactIdentifierFileStore = artifactCaches.withReadOnlyCache((md, manager) -> (ArtifactIdentifierFileStore) new TwoStageArtifactIdentifierFileStore(defaultArtifactIdentifierFileStoreFactory.create(md), writableArtifactIdentifierFileStore)).orElse(writableArtifactIdentifierFileStore);
return new FileStoreAndIndexProvider(artifactCaches.withReadOnlyCache((md, manager) -> (CachedExternalResourceIndex<String>) new TwoStageByUrlCachedExternalResourceIndex(md.getCacheDir().toPath(), prepareArtifactUrlCachedResolutionIndex(timeProvider, manager, externalResourceFileStore, md), writableByUrlCachedExternalResourceIndex)).orElse(writableByUrlCachedExternalResourceIndex), externalResourceFileStore, artifactIdentifierFileStore);
}
Aggregations