use of org.gradle.api.internal.changedetection.state.FileCollectionSnapshotter in project gradle by gradle.
the class AbstractNamedFileSnapshotTaskStateChanges method buildSnapshots.
protected static ImmutableSortedMap<String, FileCollectionSnapshot> buildSnapshots(String taskName, FileCollectionSnapshotterRegistry snapshotterRegistry, String title, SortedSet<? extends TaskFilePropertySpec> fileProperties) {
ImmutableSortedMap.Builder<String, FileCollectionSnapshot> builder = ImmutableSortedMap.naturalOrder();
for (TaskFilePropertySpec propertySpec : fileProperties) {
FileCollectionSnapshot result;
try {
FileCollectionSnapshotter snapshotter = snapshotterRegistry.getSnapshotter(propertySpec.getSnapshotter());
result = snapshotter.snapshot(propertySpec.getPropertyFiles(), propertySpec.getCompareStrategy(), propertySpec.getSnapshotNormalizationStrategy());
} catch (UncheckedIOException e) {
throw new UncheckedIOException(String.format("Failed to capture snapshot of %s files for task '%s' property '%s' during up-to-date check.", title.toLowerCase(), taskName, propertySpec.getPropertyName()), e);
}
builder.put(propertySpec.getPropertyName(), result);
}
return builder.build();
}
use of org.gradle.api.internal.changedetection.state.FileCollectionSnapshotter in project gradle by gradle.
the class TaskExecutionServices method createFileCollectionSnapshotterRegistry.
FileCollectionSnapshotterRegistry createFileCollectionSnapshotterRegistry(ServiceRegistry serviceRegistry) {
List<FileSnapshottingPropertyAnnotationHandler> handlers = serviceRegistry.getAll(FileSnapshottingPropertyAnnotationHandler.class);
ImmutableList.Builder<FileCollectionSnapshotter> snapshotters = ImmutableList.builder();
snapshotters.add(serviceRegistry.get(GenericFileCollectionSnapshotter.class));
for (FileSnapshottingPropertyAnnotationHandler handler : handlers) {
snapshotters.add(serviceRegistry.get(handler.getSnapshotterType()));
}
return new DefaultFileCollectionSnapshotterRegistry(snapshotters.build());
}
use of org.gradle.api.internal.changedetection.state.FileCollectionSnapshotter in project gradle by gradle.
the class TaskExecutionServices method createTaskArtifactStateRepository.
TaskArtifactStateRepository createTaskArtifactStateRepository(Instantiator instantiator, TaskHistoryStore cacheAccess, StartParameter startParameter, StringInterner stringInterner, FileCollectionFactory fileCollectionFactory, ClassLoaderHierarchyHasher classLoaderHierarchyHasher, FileCollectionSnapshotterRegistry fileCollectionSnapshotterRegistry, TaskCacheKeyCalculator cacheKeyCalculator, ValueSnapshotter valueSnapshotter) {
OutputFilesSnapshotter outputFilesSnapshotter = new OutputFilesSnapshotter();
SerializerRegistry serializerRegistry = new DefaultSerializerRegistry();
for (FileCollectionSnapshotter snapshotter : fileCollectionSnapshotterRegistry.getAllSnapshotters()) {
snapshotter.registerSerializers(serializerRegistry);
}
TaskHistoryRepository taskHistoryRepository = new CacheBackedTaskHistoryRepository(cacheAccess, new CacheBackedFileSnapshotRepository(cacheAccess, serializerRegistry.build(FileCollectionSnapshot.class), new RandomLongIdGenerator()), stringInterner);
return new ShortCircuitTaskArtifactStateRepository(startParameter, instantiator, new DefaultTaskArtifactStateRepository(taskHistoryRepository, instantiator, outputFilesSnapshotter, fileCollectionSnapshotterRegistry, fileCollectionFactory, classLoaderHierarchyHasher, cacheKeyCalculator, valueSnapshotter));
}
Aggregations