Search in sources :

Example 1 with OverlappingOutputs

use of org.gradle.api.internal.OverlappingOutputs in project gradle by gradle.

the class CacheBackedTaskHistoryRepository method createExecution.

private CurrentTaskExecution createExecution(TaskInternal task, TaskProperties taskProperties, @Nullable HistoricalTaskExecution previousExecution, InputNormalizationStrategy normalizationStrategy) {
    Class<? extends TaskInternal> taskClass = task.getClass();
    List<ContextAwareTaskAction> taskActions = task.getTaskActions();
    ImplementationSnapshot taskImplementation = new ImplementationSnapshot(taskClass.getName(), classLoaderHierarchyHasher.getClassLoaderHash(taskClass.getClassLoader()));
    ImmutableList<ImplementationSnapshot> taskActionImplementations = collectActionImplementations(taskActions, classLoaderHierarchyHasher);
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Implementation for {}: {}", task, taskImplementation);
        LOGGER.debug("Action implementations for {}: {}", task, taskActionImplementations);
    }
    ImmutableSortedMap<String, ValueSnapshot> previousInputProperties = previousExecution == null ? ImmutableSortedMap.<String, ValueSnapshot>of() : previousExecution.getInputProperties();
    ImmutableSortedMap<String, ValueSnapshot> inputProperties = snapshotTaskInputProperties(task, taskProperties, previousInputProperties, valueSnapshotter);
    ImmutableSortedSet<String> outputPropertyNames = getOutputPropertyNamesForCacheKey(taskProperties);
    ImmutableSet<String> declaredOutputFilePaths = getDeclaredOutputFilePaths(taskProperties, stringInterner);
    ImmutableSortedMap<String, FileCollectionSnapshot> inputFiles = snapshotTaskFiles(task, "Input", normalizationStrategy, taskProperties.getInputFileProperties(), snapshotterRegistry);
    ImmutableSortedMap<String, FileCollectionSnapshot> outputFiles = snapshotTaskFiles(task, "Output", normalizationStrategy, taskProperties.getOutputFileProperties(), snapshotterRegistry);
    FileCollectionSnapshot previousDiscoveredInputs = previousExecution == null ? null : previousExecution.getDiscoveredInputFilesSnapshot();
    FileCollectionSnapshot discoveredInputs;
    if (previousDiscoveredInputs != null) {
        discoveredInputs = snapshotDiscoveredInputs(task, normalizationStrategy, previousDiscoveredInputs.getElements(), snapshotterRegistry, fileCollectionFactory);
    } else {
        discoveredInputs = EmptyFileCollectionSnapshot.INSTANCE;
    }
    OverlappingOutputs overlappingOutputs = detectOverlappingOutputs(outputFiles, previousExecution);
    return new CurrentTaskExecution(taskImplementation, taskActionImplementations, inputProperties, outputPropertyNames, declaredOutputFilePaths, inputFiles, discoveredInputs, outputFiles, overlappingOutputs);
}
Also used : OverlappingOutputs(org.gradle.api.internal.OverlappingOutputs) ContextAwareTaskAction(org.gradle.api.internal.tasks.ContextAwareTaskAction)

Example 2 with OverlappingOutputs

use of org.gradle.api.internal.OverlappingOutputs in project gradle by gradle.

the class CacheBackedTaskHistoryRepository method detectOverlappingOutputs.

@Nullable
private static OverlappingOutputs detectOverlappingOutputs(ImmutableSortedMap<String, FileCollectionSnapshot> taskOutputs, @Nullable HistoricalTaskExecution previousExecution) {
    for (Map.Entry<String, FileCollectionSnapshot> entry : taskOutputs.entrySet()) {
        String propertyName = entry.getKey();
        FileCollectionSnapshot beforeExecution = entry.getValue();
        FileCollectionSnapshot afterPreviousExecution = getSnapshotAfterPreviousExecution(previousExecution, propertyName);
        OverlappingOutputs overlappingOutputs = OverlappingOutputs.detect(propertyName, afterPreviousExecution, beforeExecution);
        if (overlappingOutputs != null) {
            return overlappingOutputs;
        }
    }
    return null;
}
Also used : OverlappingOutputs(org.gradle.api.internal.OverlappingOutputs) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) ImmutableMap(com.google.common.collect.ImmutableMap) Nullable(javax.annotation.Nullable)

Aggregations

OverlappingOutputs (org.gradle.api.internal.OverlappingOutputs)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Nullable (javax.annotation.Nullable)1 ContextAwareTaskAction (org.gradle.api.internal.tasks.ContextAwareTaskAction)1