use of org.gradle.internal.hash.HashCode in project gradle by gradle.
the class JarCache method getCachedJar.
/**
* Returns a cached copy of the given file. The cached copy is guaranteed to not be modified or removed.
*
* @param original The source file.
* @param baseDirFactory A factory that can provide a base directory for the file cache.
* @return The cached file.
*/
public File getCachedJar(File original, Factory<File> baseDirFactory) {
HashCode hashValue = fileHasher.hash(original);
File baseDir = baseDirFactory.create();
File cachedFile = new File(baseDir, hashValue.toString() + '/' + original.getName());
if (!cachedFile.isFile()) {
GFileUtils.copyFile(original, cachedFile);
}
return cachedFile;
}
use of org.gradle.internal.hash.HashCode in project gradle by gradle.
the class ResourceSnapshotterCacheService method hashFile.
public HashCode hashFile(RegularFileSnapshot fileSnapshot, RegularFileHasher hasher, HashCode configurationHash) {
HashCode resourceHashCacheKey = resourceHashCacheKey(fileSnapshot, configurationHash);
HashCode resourceHash = persistentCache.get(resourceHashCacheKey);
if (resourceHash != null) {
if (resourceHash.equals(NO_HASH)) {
return null;
}
return resourceHash;
}
resourceHash = hasher.hash(fileSnapshot);
if (resourceHash != null) {
persistentCache.put(resourceHashCacheKey, resourceHash);
} else {
persistentCache.put(resourceHashCacheKey, NO_HASH);
}
return resourceHash;
}
use of org.gradle.internal.hash.HashCode in project gradle by gradle.
the class DefaultTaskOutputCachingBuildCacheKeyBuilder method build.
@Override
public TaskOutputCachingBuildCacheKey build() {
BuildCacheKeyInputs inputs = new BuildCacheKeyInputs(taskClass, classLoaderHash, actionClassLoaderHashes, actionTypes, inputHashes.build(), inputPropertiesLoadedByUnknownClassLoader.build(), outputPropertyNames.build());
HashCode hash;
if (!valid) {
hash = null;
} else {
hash = hasher.hash();
}
return new DefaultTaskOutputCachingBuildCacheKey(taskPath, hash, inputs);
}
use of org.gradle.internal.hash.HashCode in project gradle by gradle.
the class DefaultTaskOutputCachingBuildCacheKeyBuilder method appendTaskImplementation.
@Override
public void appendTaskImplementation(ImplementationSnapshot taskImplementation) {
this.taskClass = taskImplementation.getTypeName();
hasher.putString(taskClass);
if (taskImplementation.hasUnknownClassLoader()) {
valid = false;
} else {
HashCode hashCode = taskImplementation.getClassLoaderHash();
this.classLoaderHash = hashCode;
hasher.putHash(hashCode);
}
}
use of org.gradle.internal.hash.HashCode in project gradle by gradle.
the class DefaultTaskOutputCachingBuildCacheKeyBuilder method appendTaskActionImplementations.
@Override
public void appendTaskActionImplementations(Collection<ImplementationSnapshot> taskActionImplementations) {
ImmutableList.Builder<String> actionTypes = ImmutableList.builder();
List<HashCode> actionClassLoaderHashes = Lists.newArrayListWithCapacity(taskActionImplementations.size());
for (ImplementationSnapshot actionImpl : taskActionImplementations) {
String actionType = actionImpl.getTypeName();
actionTypes.add(actionType);
hasher.putString(actionType);
HashCode hashCode;
if (actionImpl.hasUnknownClassLoader()) {
hashCode = null;
valid = false;
} else {
hashCode = actionImpl.getClassLoaderHash();
hasher.putHash(hashCode);
}
actionClassLoaderHashes.add(hashCode);
}
this.actionTypes = actionTypes.build();
this.actionClassLoaderHashes = Collections.unmodifiableList(actionClassLoaderHashes);
}
Aggregations