use of org.gradle.execution.plan.Node in project gradle by gradle.
the class DefaultBuildController method visitDependenciesOf.
private void visitDependenciesOf(TaskInternal task, Consumer<TaskInternal> consumer) {
TaskNodeFactory taskNodeFactory = ((GradleInternal) task.getProject().getGradle()).getServices().get(TaskNodeFactory.class);
TaskNode node = taskNodeFactory.getOrCreateNode(task);
for (Node dependency : node.getAllSuccessors()) {
if (dependency instanceof TaskNode) {
consumer.accept(((TaskNode) dependency).getTask());
}
}
}
use of org.gradle.execution.plan.Node in project gradle by gradle.
the class DefaultTaskExecutionGraph method getDependencies.
@Override
public Set<Task> getDependencies(Task task) {
Node node = executionPlan.getNode(task);
ImmutableSet.Builder<Task> builder = ImmutableSet.builder();
for (Node dependencyNode : node.getDependencySuccessors()) {
if (dependencyNode instanceof TaskNode) {
builder.add(((TaskNode) dependencyNode).getTask());
}
}
return builder.build();
}
use of org.gradle.execution.plan.Node in project gradle by gradle.
the class TransformationNode method processDependencies.
protected void processDependencies(Action<Node> processHardSuccessor, Set<Node> dependencies) {
for (Node dependency : dependencies) {
addDependencySuccessor(dependency);
processHardSuccessor.execute(dependency);
}
}
use of org.gradle.execution.plan.Node in project gradle by gradle.
the class DefaultBuildController method checkForCyclesFor.
private void checkForCyclesFor(TaskInternal task, Set<TaskInternal> visited, Set<TaskInternal> visiting) {
if (visited.contains(task)) {
// Already checked
return;
}
if (!visiting.add(task)) {
// Visiting dependencies -> have found a cycle
CachingDirectedGraphWalker<TaskInternal, Void> graphWalker = new CachingDirectedGraphWalker<>((node, values, connectedNodes) -> visitDependenciesOf(node, connectedNodes::add));
graphWalker.add(task);
List<Set<TaskInternal>> cycles = graphWalker.findCycles();
Set<TaskInternal> cycle = cycles.get(0);
DirectedGraphRenderer<TaskInternal> graphRenderer = new DirectedGraphRenderer<>((node, output) -> output.withStyle(StyledTextOutput.Style.Identifier).text(node.getIdentityPath()), (node, values, connectedNodes) -> visitDependenciesOf(node, dep -> {
if (cycle.contains(dep)) {
connectedNodes.add(dep);
}
}));
StringWriter writer = new StringWriter();
graphRenderer.renderTo(task, writer);
throw new CircularReferenceException(String.format("Circular dependency between the following tasks:%n%s", writer));
}
visitDependenciesOf(task, dep -> checkForCyclesFor(dep, visited, visiting));
visiting.remove(task);
visited.add(task);
}
Aggregations