use of org.gradle.api.internal.tasks.TaskLocalStateInternal 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