Search in sources :

Example 16 with HashCode

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

the class JarSnapshot method affectedSince.

private DependentsSet affectedSince(JarSnapshot other) {
    final Set<String> affected = new HashSet<String>();
    for (Map.Entry<String, HashCode> otherClass : other.getHashes().entrySet()) {
        String otherClassName = otherClass.getKey();
        HashCode otherClassBytes = otherClass.getValue();
        HashCode thisClsBytes = getHashes().get(otherClassName);
        if (thisClsBytes == null || !thisClsBytes.equals(otherClassBytes)) {
            // removed since or changed since
            affected.add(otherClassName);
            DependentsSet dependents = other.getAnalysis().getRelevantDependents(otherClassName, IntSets.EMPTY_SET);
            if (dependents.isDependencyToAll()) {
                return dependents;
            }
            affected.addAll(dependents.getDependentClasses());
        }
    }
    return DependentsSet.dependents(affected);
}
Also used : HashCode(org.gradle.internal.hash.HashCode) DependentsSet(org.gradle.api.internal.tasks.compile.incremental.deps.DependentsSet) Map(java.util.Map) HashSet(java.util.HashSet) IntOpenHashSet(it.unimi.dsi.fastutil.ints.IntOpenHashSet)

Example 17 with HashCode

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

the class CacheBackedTaskHistoryRepository method collectActionImplementations.

private static ImmutableList<ImplementationSnapshot> collectActionImplementations(Collection<ContextAwareTaskAction> taskActions, ClassLoaderHierarchyHasher classLoaderHierarchyHasher) {
    if (taskActions.isEmpty()) {
        return ImmutableList.of();
    }
    ImmutableList.Builder<ImplementationSnapshot> actionImplementations = ImmutableList.builder();
    for (ContextAwareTaskAction taskAction : taskActions) {
        String typeName = taskAction.getActionClassName();
        HashCode classLoaderHash = classLoaderHierarchyHasher.getClassLoaderHash(taskAction.getClassLoader());
        actionImplementations.add(new ImplementationSnapshot(typeName, classLoaderHash));
    }
    return actionImplementations.build();
}
Also used : HashCode(org.gradle.internal.hash.HashCode) ContextAwareTaskAction(org.gradle.api.internal.tasks.ContextAwareTaskAction) ImmutableList(com.google.common.collect.ImmutableList)

Example 18 with HashCode

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

the class CachingFileHasher method snapshot.

private FileInfo snapshot(File file, long length, long timestamp) {
    String absolutePath = file.getAbsolutePath();
    if (timestampInspector.timestampCanBeUsedToDetectFileChange(absolutePath, timestamp)) {
        FileInfo info = cache.get(absolutePath);
        if (info != null && length == info.length && timestamp == info.timestamp) {
            return info;
        }
    }
    HashCode hash = delegate.hash(file);
    FileInfo info = new FileInfo(hash, length, timestamp);
    cache.put(stringInterner.intern(absolutePath), info);
    return info;
}
Also used : HashCode(org.gradle.internal.hash.HashCode)

Example 19 with HashCode

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

the class DefaultHashingClassLoaderFactory method createChildClassLoader.

@Override
public ClassLoader createChildClassLoader(ClassLoader parent, ClassPath classPath, HashCode implementationHash) {
    HashCode hashCode = implementationHash != null ? implementationHash : calculateClassLoaderHash(classPath);
    ClassLoader classLoader = super.doCreateClassLoader(parent, classPath);
    hashCodes.put(classLoader, hashCode);
    return classLoader;
}
Also used : HashCode(org.gradle.internal.hash.HashCode)

Aggregations

HashCode (org.gradle.internal.hash.HashCode)19 File (java.io.File)4 ImmutableList (com.google.common.collect.ImmutableList)2 Map (java.util.Map)2 ClassAnalysis (org.gradle.api.internal.tasks.compile.incremental.deps.ClassAnalysis)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 IntOpenHashSet (it.unimi.dsi.fastutil.ints.IntOpenHashSet)1 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 SortedMap (java.util.SortedMap)1 TarArchiveOutputStream (org.apache.commons.compress.archivers.tar.TarArchiveOutputStream)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 FileVisitDetails (org.gradle.api.file.FileVisitDetails)1