Search in sources :

Example 1 with SerializerRegistry

use of org.gradle.internal.serialize.SerializerRegistry in project gradle by gradle.

the class DefaultMethodArgsSerializer method forTypes.

@Override
public Serializer<Object[]> forTypes(Class<?>[] types) {
    if (types.length == 0) {
        return new EmptyArraySerializer();
    }
    SerializerRegistry selected = null;
    for (SerializerRegistry serializerRegistry : serializerRegistries) {
        if (serializerRegistry.canSerialize(types[0])) {
            selected = serializerRegistry;
            break;
        }
    }
    if (selected == null) {
        return defaultArgsSerializer.forTypes(types);
    }
    final Serializer<Object>[] serializers = new Serializer[types.length];
    for (int i = 0; i < types.length; i++) {
        Class<?> type = types[i];
        serializers[i] = (Serializer<Object>) selected.build(type);
    }
    return new ArraySerializer(serializers);
}
Also used : SerializerRegistry(org.gradle.internal.serialize.SerializerRegistry) Serializer(org.gradle.internal.serialize.Serializer)

Example 2 with SerializerRegistry

use of org.gradle.internal.serialize.SerializerRegistry 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

SerializerRegistry (org.gradle.internal.serialize.SerializerRegistry)2 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 DefaultGenericFileCollectionSnapshotter (org.gradle.api.internal.changedetection.state.DefaultGenericFileCollectionSnapshotter)1 FileCollectionSnapshotter (org.gradle.api.internal.changedetection.state.FileCollectionSnapshotter)1 GenericFileCollectionSnapshotter (org.gradle.api.internal.changedetection.state.GenericFileCollectionSnapshotter)1 OutputFilesSnapshotter (org.gradle.api.internal.changedetection.state.OutputFilesSnapshotter)1 TaskHistoryRepository (org.gradle.api.internal.changedetection.state.TaskHistoryRepository)1 RandomLongIdGenerator (org.gradle.internal.id.RandomLongIdGenerator)1 DefaultSerializerRegistry (org.gradle.internal.serialize.DefaultSerializerRegistry)1 Serializer (org.gradle.internal.serialize.Serializer)1