use of org.gradle.caching.internal.DefaultBuildCacheHasher in project gradle by gradle.
the class DefaultClasspathHasher method hash.
@Override
public HashCode hash(ClassPath classpath) {
FileCollectionSnapshot snapshot = snapshotter.snapshot(new SimpleFileCollection(classpath.getAsFiles()), TaskFilePropertyCompareStrategy.ORDERED, ClasspathSnapshotNormalizationStrategy.INSTANCE);
BuildCacheHasher hasher = new DefaultBuildCacheHasher();
snapshot.appendToHasher(hasher);
return hasher.hash();
}
use of org.gradle.caching.internal.DefaultBuildCacheHasher in project gradle by gradle.
the class TaskCacheKeyCalculator method calculate.
public TaskOutputCachingBuildCacheKey calculate(TaskExecution execution) {
DefaultTaskOutputCachingBuildCacheKeyBuilder builder = new DefaultTaskOutputCachingBuildCacheKeyBuilder();
HashCode taskClassLoaderHash = execution.getTaskClassLoaderHash();
List<HashCode> taskActionsClassLoaderHashes = execution.getTaskActionsClassLoaderHashes();
builder.appendTaskClass(execution.getTaskClass());
builder.appendClassloaderHash(taskClassLoaderHash);
builder.appendActionsClassloaderHashes(taskActionsClassLoaderHashes);
SortedMap<String, ValueSnapshot> inputProperties = execution.getInputProperties();
for (Map.Entry<String, ValueSnapshot> entry : inputProperties.entrySet()) {
DefaultBuildCacheHasher newHasher = new DefaultBuildCacheHasher();
entry.getValue().appendToHasher(newHasher);
HashCode hash = newHasher.hash();
builder.appendInputPropertyHash(entry.getKey(), hash);
}
SortedMap<String, FileCollectionSnapshot> inputFilesSnapshots = execution.getInputFilesSnapshot();
for (Map.Entry<String, FileCollectionSnapshot> entry : inputFilesSnapshots.entrySet()) {
FileCollectionSnapshot snapshot = entry.getValue();
DefaultBuildCacheHasher newHasher = new DefaultBuildCacheHasher();
snapshot.appendToHasher(newHasher);
HashCode hash = newHasher.hash();
builder.appendInputPropertyHash(entry.getKey(), hash);
}
SortedSet<String> outputPropertyNamesForCacheKey = execution.getOutputPropertyNamesForCacheKey();
for (String cacheableOutputPropertyName : outputPropertyNamesForCacheKey) {
builder.appendOutputPropertyName(cacheableOutputPropertyName);
}
return builder.build();
}
use of org.gradle.caching.internal.DefaultBuildCacheHasher in project gradle by gradle.
the class DefaultVariantTransformRegistration method transform.
@Override
public List<File> transform(File input) {
try {
File absoluteFile = input.getAbsoluteFile();
// Collect up hash of the input files, and of the transform's configuration params and implementation
FileCollectionSnapshot snapshot = fileCollectionSnapshotter.snapshot(new SimpleFileCollection(absoluteFile), TaskFilePropertyCompareStrategy.UNORDERED, TaskFilePropertySnapshotNormalizationStrategy.ABSOLUTE);
DefaultBuildCacheHasher hasher = new DefaultBuildCacheHasher();
hasher.putBytes(inputsHash.asBytes());
snapshot.appendToHasher(hasher);
HashCode resultHash = hasher.hash();
return transformedFileCache.getResult(absoluteFile, resultHash, transformer);
} catch (Exception e) {
throw new ArtifactTransformException(input, to, implementation, e);
}
}
Aggregations