Search in sources :

Example 1 with Hasher

use of org.gradle.internal.hash.Hasher in project gradle by gradle.

the class DefaultScriptSourceHasher method hash.

@Override
public HashCode hash(ScriptSource scriptSource) {
    TextResource resource = scriptSource.getResource();
    File file = resource.getFile();
    if (file != null) {
        try {
            return fileHasher.hash(file);
        } catch (UncheckedIOException e) {
            if (e.getCause() instanceof FileNotFoundException) {
                throw new UncheckedIOException("Could not read " + scriptSource.getDisplayName() + " as it does not exist.", e.getCause());
            }
            throw e;
        }
    }
    Hasher hasher = contentHasherFactory.create();
    hasher.putString(resource.getText());
    return hasher.hash();
}
Also used : TextResource(org.gradle.internal.resource.TextResource) FileHasher(org.gradle.internal.hash.FileHasher) Hasher(org.gradle.internal.hash.Hasher) FileNotFoundException(java.io.FileNotFoundException) UncheckedIOException(org.gradle.api.UncheckedIOException) File(java.io.File)

Example 2 with Hasher

use of org.gradle.internal.hash.Hasher in project gradle by gradle.

the class DefaultHashingClassLoaderFactory method calculateFilterSpecHash.

private static HashCode calculateFilterSpecHash(FilteringClassLoader.Spec spec) {
    Hasher hasher = Hashing.md5().newHasher();
    addToHash(hasher, spec.getClassNames());
    addToHash(hasher, spec.getPackageNames());
    addToHash(hasher, spec.getPackagePrefixes());
    addToHash(hasher, spec.getResourcePrefixes());
    addToHash(hasher, spec.getResourceNames());
    addToHash(hasher, spec.getDisallowedClassNames());
    addToHash(hasher, spec.getDisallowedPackagePrefixes());
    return hasher.hash();
}
Also used : Hasher(org.gradle.internal.hash.Hasher)

Aggregations

Hasher (org.gradle.internal.hash.Hasher)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 FileHasher (org.gradle.internal.hash.FileHasher)1 TextResource (org.gradle.internal.resource.TextResource)1