Search in sources :

Example 6 with FileCollectionSnapshot

use of org.gradle.api.internal.changedetection.state.FileCollectionSnapshot in project gradle by gradle.

the class DefaultClasspathHasher method hash.

@Override
public HashCode hash(ClassPath classpath) {
    FileCollectionSnapshot snapshot = snapshotter.snapshot(new SimpleFileCollection(classpath.getAsFiles()), null, InputNormalizationStrategy.NOT_CONFIGURED);
    BuildCacheHasher hasher = new DefaultBuildCacheHasher();
    snapshot.appendToHasher(hasher);
    return hasher.hash();
}
Also used : SimpleFileCollection(org.gradle.api.internal.file.collections.SimpleFileCollection) FileCollectionSnapshot(org.gradle.api.internal.changedetection.state.FileCollectionSnapshot) DefaultBuildCacheHasher(org.gradle.caching.internal.DefaultBuildCacheHasher) BuildCacheHasher(org.gradle.caching.internal.BuildCacheHasher) DefaultBuildCacheHasher(org.gradle.caching.internal.DefaultBuildCacheHasher)

Example 7 with FileCollectionSnapshot

use of org.gradle.api.internal.changedetection.state.FileCollectionSnapshot in project gradle by gradle.

the class TaskCacheKeyCalculator method calculate.

public TaskOutputCachingBuildCacheKey calculate(TaskInternal task, TaskExecution execution) {
    TaskOutputCachingBuildCacheKeyBuilder builder = new DefaultTaskOutputCachingBuildCacheKeyBuilder(task.getIdentityPath());
    if (buildCacheDebugLogging) {
        builder = new DebuggingTaskOutputCachingBuildCacheKeyBuilder(builder);
    }
    builder.appendTaskImplementation(execution.getTaskImplementation());
    builder.appendTaskActionImplementations(execution.getTaskActionImplementations());
    SortedMap<String, ValueSnapshot> inputProperties = execution.getInputProperties();
    for (Map.Entry<String, ValueSnapshot> entry : inputProperties.entrySet()) {
        DefaultBuildCacheHasher newHasher = new DefaultBuildCacheHasher();
        entry.getValue().appendToHasher(newHasher);
        if (newHasher.isValid()) {
            HashCode hash = newHasher.hash();
            builder.appendInputPropertyHash(entry.getKey(), hash);
        } else {
            builder.inputPropertyLoadedByUnknownClassLoader(entry.getKey());
        }
    }
    SortedMap<String, FileCollectionSnapshot> inputFilesSnapshots = execution.getInputFilesSnapshot();
    for (Map.Entry<String, FileCollectionSnapshot> entry : inputFilesSnapshots.entrySet()) {
        FileCollectionSnapshot snapshot = entry.getValue();
        builder.appendInputPropertyHash(entry.getKey(), snapshot.getHash());
    }
    SortedSet<String> outputPropertyNamesForCacheKey = execution.getOutputPropertyNamesForCacheKey();
    for (String cacheableOutputPropertyName : outputPropertyNamesForCacheKey) {
        builder.appendOutputPropertyName(cacheableOutputPropertyName);
    }
    return builder.build();
}
Also used : ValueSnapshot(org.gradle.api.internal.changedetection.state.ValueSnapshot) DefaultBuildCacheHasher(org.gradle.caching.internal.DefaultBuildCacheHasher) HashCode(org.gradle.internal.hash.HashCode) FileCollectionSnapshot(org.gradle.api.internal.changedetection.state.FileCollectionSnapshot) Map(java.util.Map) SortedMap(java.util.SortedMap)

Aggregations

FileCollectionSnapshot (org.gradle.api.internal.changedetection.state.FileCollectionSnapshot)7 DefaultBuildCacheHasher (org.gradle.caching.internal.DefaultBuildCacheHasher)4 HashCode (com.google.common.hash.HashCode)2 Map (java.util.Map)2 SortedMap (java.util.SortedMap)2 ValueSnapshot (org.gradle.api.internal.changedetection.state.ValueSnapshot)2 SimpleFileCollection (org.gradle.api.internal.file.collections.SimpleFileCollection)2 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 File (java.io.File)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 ArtifactTransformException (org.gradle.api.artifacts.transform.ArtifactTransformException)1 VariantTransformConfigurationException (org.gradle.api.artifacts.transform.VariantTransformConfigurationException)1 FileCollectionSnapshotter (org.gradle.api.internal.changedetection.state.FileCollectionSnapshotter)1 TaskFilePropertySpec (org.gradle.api.internal.tasks.TaskFilePropertySpec)1 BuildCacheHasher (org.gradle.caching.internal.BuildCacheHasher)1 HashCode (org.gradle.internal.hash.HashCode)1