use of org.gradle.api.internal.tasks.ContextAwareTaskAction 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);
}
use of org.gradle.api.internal.tasks.ContextAwareTaskAction in project gradle by gradle.
the class ExecuteActionsTaskExecuter method executeActions.
private GradleException executeActions(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
LOGGER.debug("Executing actions for {}.", task);
final List<ContextAwareTaskAction> actions = new ArrayList<ContextAwareTaskAction>(task.getTaskActions());
for (ContextAwareTaskAction action : actions) {
state.setDidWork(true);
task.getStandardOutputCapture().start();
try {
executeAction(action.getDisplayName(), task, action, context);
} catch (StopActionException e) {
// Ignore
LOGGER.debug("Action stopped by some action with message: {}", e.getMessage());
} catch (StopExecutionException e) {
LOGGER.info("Execution stopped by some action with message: {}", e.getMessage());
break;
} catch (Throwable t) {
return new TaskExecutionException(task, t);
} finally {
task.getStandardOutputCapture().stop();
}
}
return null;
}
use of org.gradle.api.internal.tasks.ContextAwareTaskAction 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();
}
Aggregations