use of org.gradle.api.internal.tasks.properties.PropertyWalker in project gradle by gradle.
the class DefaultTaskExecutionPlan method getResolvedTaskMutationInfo.
private TaskMutationInfo getResolvedTaskMutationInfo(TaskInfo taskInfo) {
TaskInternal task = taskInfo.getTask();
TaskMutationInfo taskMutationInfo = taskMutations.get(taskInfo);
if (!taskMutationInfo.resolved) {
ProjectInternal project = (ProjectInternal) task.getProject();
ServiceRegistry serviceRegistry = project.getServices();
PathToFileResolver resolver = serviceRegistry.get(PathToFileResolver.class);
PropertyWalker propertyWalker = serviceRegistry.get(PropertyWalker.class);
TaskProperties taskProperties = DefaultTaskProperties.resolve(propertyWalker, resolver, task);
taskMutationInfo.outputPaths.addAll(getOutputPaths(canonicalizedFileCache, taskInfo, taskProperties.getOutputFiles(), taskProperties.getLocalStateFiles()));
taskMutationInfo.destroyablePaths.addAll(getDestroyablePaths(canonicalizedFileCache, taskInfo, taskProperties.getDestroyableFiles()));
taskMutationInfo.hasFileInputs = !taskProperties.getInputFileProperties().isEmpty();
taskMutationInfo.hasOutputs = taskProperties.hasDeclaredOutputs();
taskMutationInfo.hasLocalState = !taskProperties.getLocalStateFiles().isEmpty();
taskMutationInfo.resolved = true;
}
return taskMutationInfo;
}
use of org.gradle.api.internal.tasks.properties.PropertyWalker in project gradle by gradle.
the class LocalTaskNode method resolveMutations.
@Override
public void resolveMutations() {
final LocalTaskNode taskNode = this;
final TaskInternal task = getTask();
final MutationInfo mutations = getMutationInfo();
ProjectInternal project = (ProjectInternal) task.getProject();
ServiceRegistry serviceRegistry = project.getServices();
final FileCollectionFactory fileCollectionFactory = serviceRegistry.get(FileCollectionFactory.class);
PropertyWalker propertyWalker = serviceRegistry.get(PropertyWalker.class);
try {
taskProperties = DefaultTaskProperties.resolve(propertyWalker, fileCollectionFactory, task);
addOutputFilesToMutations(taskProperties.getOutputFileProperties());
addLocalStateFilesToMutations(taskProperties.getLocalStateFiles());
addDestroyablesToMutations(taskProperties.getDestroyableFiles());
mutations.hasFileInputs = !taskProperties.getInputFileProperties().isEmpty();
} catch (Exception e) {
throw new TaskExecutionException(task, e);
}
mutations.resolved = true;
if (!mutations.destroyablePaths.isEmpty()) {
if (mutations.hasOutputs) {
throw new IllegalStateException("Task " + taskNode + " has both outputs and destroyables defined. A task can define either outputs or destroyables, but not both.");
}
if (mutations.hasFileInputs) {
throw new IllegalStateException("Task " + taskNode + " has both inputs and destroyables defined. A task can define either inputs or destroyables, but not both.");
}
if (mutations.hasLocalState) {
throw new IllegalStateException("Task " + taskNode + " has both local state and destroyables defined. A task can define either local state or destroyables, but not both.");
}
}
}
use of org.gradle.api.internal.tasks.properties.PropertyWalker in project gradle by gradle.
the class DefaultExecutionPlan method createOrdinalRelationships.
private void createOrdinalRelationships(Node node) {
if (node instanceof TaskNode && ((TaskNode) node).getOrdinal() != TaskNode.UNKNOWN_ORDINAL) {
TaskNode taskNode = (TaskNode) node;
TaskClassifier taskClassifier = new TaskClassifier();
ProjectInternal project = (ProjectInternal) taskNode.getTask().getProject();
ServiceRegistry serviceRegistry = project.getServices();
PropertyWalker propertyWalker = serviceRegistry.get(PropertyWalker.class);
// Walk the properties of the task to determine if it is a destroyer or a producer (or neither)
propertyWalker.visitProperties(taskNode.getTask(), TypeValidationContext.NOOP, taskClassifier);
taskNode.getTask().getOutputs().visitRegisteredProperties(taskClassifier);
((TaskDestroyablesInternal) taskNode.getTask().getDestroyables()).visitRegisteredProperties(taskClassifier);
((TaskLocalStateInternal) taskNode.getTask().getLocalState()).visitRegisteredProperties(taskClassifier);
if (taskClassifier.isDestroyer()) {
// Create (or get) a destroyer ordinal node that depends on the dependencies of this task node
Node ordinalNode = ordinalNodeAccess.getOrCreateDestroyableLocationNode(taskNode.getOrdinal());
taskNode.getHardSuccessors().forEach(ordinalNode::addDependencySuccessor);
if (taskNode.getOrdinal() > 0) {
// Depend on any previous producer ordinal nodes (i.e. any producer ordinal nodes with a lower
// ordinal)
ordinalNodeAccess.getPrecedingProducerLocationNodes(taskNode.getOrdinal()).forEach(taskNode::addDependencySuccessor);
}
} else if (taskClassifier.isProducer()) {
// Create (or get) a producer ordinal node that depends on the dependencies of this task node
Node ordinalNode = ordinalNodeAccess.getOrCreateOutputLocationNode(taskNode.getOrdinal());
taskNode.getHardSuccessors().forEach(ordinalNode::addDependencySuccessor);
if (taskNode.getOrdinal() > 0) {
// Depend on any previous destroyer ordinal nodes (i.e. any destroyer ordinal nodes with a lower
// ordinal)
ordinalNodeAccess.getPrecedingDestroyerLocationNodes(taskNode.getOrdinal()).forEach(taskNode::addDependencySuccessor);
}
}
}
}
Aggregations