Search in sources :

Example 1 with FileCollectionSnapshotter

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();
}
Also used : FileCollectionSnapshot(org.gradle.api.internal.changedetection.state.FileCollectionSnapshot) TaskFilePropertySpec(org.gradle.api.internal.tasks.TaskFilePropertySpec) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) UncheckedIOException(org.gradle.api.UncheckedIOException) FileCollectionSnapshotter(org.gradle.api.internal.changedetection.state.FileCollectionSnapshotter)

Example 2 with FileCollectionSnapshotter

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());
}
Also used : DefaultGenericFileCollectionSnapshotter(org.gradle.api.internal.changedetection.state.DefaultGenericFileCollectionSnapshotter) GenericFileCollectionSnapshotter(org.gradle.api.internal.changedetection.state.GenericFileCollectionSnapshotter) ImmutableList(com.google.common.collect.ImmutableList) FileSnapshottingPropertyAnnotationHandler(org.gradle.api.internal.project.taskfactory.FileSnapshottingPropertyAnnotationHandler) DefaultFileCollectionSnapshotterRegistry(org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotterRegistry) DefaultGenericFileCollectionSnapshotter(org.gradle.api.internal.changedetection.state.DefaultGenericFileCollectionSnapshotter) FileCollectionSnapshotter(org.gradle.api.internal.changedetection.state.FileCollectionSnapshotter) GenericFileCollectionSnapshotter(org.gradle.api.internal.changedetection.state.GenericFileCollectionSnapshotter)

Example 3 with FileCollectionSnapshotter

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));
}
Also used : ShortCircuitTaskArtifactStateRepository(org.gradle.api.internal.changedetection.changes.ShortCircuitTaskArtifactStateRepository) CacheBackedTaskHistoryRepository(org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository) TaskHistoryRepository(org.gradle.api.internal.changedetection.state.TaskHistoryRepository) OutputFilesSnapshotter(org.gradle.api.internal.changedetection.state.OutputFilesSnapshotter) DefaultSerializerRegistry(org.gradle.internal.serialize.DefaultSerializerRegistry) SerializerRegistry(org.gradle.internal.serialize.SerializerRegistry) CacheBackedTaskHistoryRepository(org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository) RandomLongIdGenerator(org.gradle.internal.id.RandomLongIdGenerator) DefaultSerializerRegistry(org.gradle.internal.serialize.DefaultSerializerRegistry) CacheBackedFileSnapshotRepository(org.gradle.api.internal.changedetection.state.CacheBackedFileSnapshotRepository) DefaultTaskArtifactStateRepository(org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository) DefaultGenericFileCollectionSnapshotter(org.gradle.api.internal.changedetection.state.DefaultGenericFileCollectionSnapshotter) FileCollectionSnapshotter(org.gradle.api.internal.changedetection.state.FileCollectionSnapshotter) GenericFileCollectionSnapshotter(org.gradle.api.internal.changedetection.state.GenericFileCollectionSnapshotter)

Aggregations

FileCollectionSnapshotter (org.gradle.api.internal.changedetection.state.FileCollectionSnapshotter)3 DefaultGenericFileCollectionSnapshotter (org.gradle.api.internal.changedetection.state.DefaultGenericFileCollectionSnapshotter)2 GenericFileCollectionSnapshotter (org.gradle.api.internal.changedetection.state.GenericFileCollectionSnapshotter)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 DefaultTaskArtifactStateRepository (org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository)1 ShortCircuitTaskArtifactStateRepository (org.gradle.api.internal.changedetection.changes.ShortCircuitTaskArtifactStateRepository)1 CacheBackedFileSnapshotRepository (org.gradle.api.internal.changedetection.state.CacheBackedFileSnapshotRepository)1 CacheBackedTaskHistoryRepository (org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository)1 DefaultFileCollectionSnapshotterRegistry (org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotterRegistry)1 FileCollectionSnapshot (org.gradle.api.internal.changedetection.state.FileCollectionSnapshot)1 OutputFilesSnapshotter (org.gradle.api.internal.changedetection.state.OutputFilesSnapshotter)1 TaskHistoryRepository (org.gradle.api.internal.changedetection.state.TaskHistoryRepository)1 FileSnapshottingPropertyAnnotationHandler (org.gradle.api.internal.project.taskfactory.FileSnapshottingPropertyAnnotationHandler)1 TaskFilePropertySpec (org.gradle.api.internal.tasks.TaskFilePropertySpec)1 RandomLongIdGenerator (org.gradle.internal.id.RandomLongIdGenerator)1 DefaultSerializerRegistry (org.gradle.internal.serialize.DefaultSerializerRegistry)1 SerializerRegistry (org.gradle.internal.serialize.SerializerRegistry)1