use of org.gradle.internal.logging.text.LinePrefixingStyledTextOutput in project gradle by gradle.
the class TreeFormatter method writeNode.
private void writeNode(Node node) {
if (node.prefix == null) {
node.prefix = node.isTopLevelNode() ? "" : node.parent.prefix + " ";
}
StyledTextOutput output = new LinePrefixingStyledTextOutput(original, node.prefix, false);
if (!node.valueWritten) {
output.append(node.parent.prefix);
output.append(" - ");
output.append(node.value);
}
if (node.canCollapseFirstChild()) {
output.append(": ");
Node firstChild = node.firstChild;
output.append(firstChild.value);
firstChild.valueWritten = true;
firstChild.prefix = node.prefix;
writeNode(firstChild);
} else if (node.firstChild != null) {
original.format(":%n");
writeNode(node.firstChild);
}
if (node.nextSibling != null) {
original.format("%n");
writeNode(node.nextSibling);
}
}
use of org.gradle.internal.logging.text.LinePrefixingStyledTextOutput in project gradle by gradle.
the class DefaultTextReportBuilder method item.
@Override
public void item(String title, String value) {
hasTitledItems = true;
StyledTextOutput itemOutput = new LinePrefixingStyledTextOutput(textOutput, INDENT, false);
itemOutput.append(title).append(": ");
itemOutput.append(value).println();
}
use of org.gradle.internal.logging.text.LinePrefixingStyledTextOutput in project gradle by gradle.
the class TaskDetailPrinter method printTaskAttribute.
private void printTaskAttribute(StyledTextOutput output, String attributeHeader, List<Task> tasks, Transformer<String, Task> transformer) {
int count = collect(tasks, new HashSet<String>(), transformer).size();
final LinePrefixingStyledTextOutput attributeOutput = createIndentedOutput(output, INDENT);
if (count == 1) {
// all tasks have the same value
attributeOutput.println(attributeHeader);
final Task task = tasks.iterator().next();
String value = transformer.transform(task);
attributeOutput.println(value == null ? "-" : value);
} else {
attributeOutput.println(attributeHeader + "s");
for (Task task : tasks) {
attributeOutput.withStyle(UserInput).text("(" + task.getPath() + ") ");
String value = transformer.transform(task);
attributeOutput.println(value == null ? "-" : value);
}
}
}
use of org.gradle.internal.logging.text.LinePrefixingStyledTextOutput in project gradle by gradle.
the class TaskDetailPrinter method print.
public void print(StyledTextOutput output) {
final List<Task> tasks = sort(selection.getTasks());
output.text("Detailed task information for ").withStyle(UserInput).println(taskPath);
final ListMultimap<Class, Task> classListMap = groupTasksByType(tasks);
final Set<Class> classes = classListMap.keySet();
boolean multipleClasses = classes.size() > 1;
final List<Class> sortedClasses = sort(classes, new Comparator<Class>() {
public int compare(Class o1, Class o2) {
return o1.getSimpleName().compareTo(o2.getSimpleName());
}
});
for (Class clazz : sortedClasses) {
output.println();
final List<Task> tasksByType = classListMap.get(clazz);
final LinePrefixingStyledTextOutput pathOutput = createIndentedOutput(output, INDENT);
pathOutput.println(tasksByType.size() > 1 ? "Paths" : "Path");
for (Task task : tasksByType) {
pathOutput.withStyle(UserInput).println(task.getPath());
}
output.println();
final LinePrefixingStyledTextOutput typeOutput = createIndentedOutput(output, INDENT);
typeOutput.println("Type");
typeOutput.withStyle(UserInput).text(clazz.getSimpleName());
typeOutput.println(" (" + clazz.getName() + ")");
printlnCommandlineOptions(output, tasksByType);
output.println();
printTaskDescription(output, tasksByType);
output.println();
printTaskGroup(output, tasksByType);
if (multipleClasses) {
output.println();
output.println("----------------------");
}
}
}
use of org.gradle.internal.logging.text.LinePrefixingStyledTextOutput in project gradle by gradle.
the class BuildExceptionReporter method formatGenericFailure.
private void formatGenericFailure(String granularity, Throwable failure, final FailureDetails details) {
details.summary.format("%s failed with an exception.", granularity);
fillInFailureResolution(details);
if (failure instanceof LocationAwareException) {
final LocationAwareException scriptException = (LocationAwareException) failure;
details.failure = scriptException.getCause();
if (scriptException.getLocation() != null) {
details.location.text(scriptException.getLocation());
}
scriptException.visitReportableCauses(new TreeVisitor<Throwable>() {
int depth;
@Override
public void node(final Throwable node) {
if (node == scriptException) {
details.details.text(getMessage(scriptException.getCause()));
} else {
final LinePrefixingStyledTextOutput output = getLinePrefixingStyledTextOutput();
output.text(getMessage(node));
}
}
@Override
public void startChildren() {
depth++;
}
@Override
public void endChildren() {
depth--;
}
private LinePrefixingStyledTextOutput getLinePrefixingStyledTextOutput() {
details.details.format("%n");
StringBuilder prefix = new StringBuilder();
for (int i = 1; i < depth; i++) {
prefix.append(" ");
}
details.details.text(prefix);
prefix.append(" ");
details.details.style(Info).text("> ").style(Normal);
return new LinePrefixingStyledTextOutput(details.details, prefix, false);
}
});
} else {
details.details.text(getMessage(failure));
}
}
Aggregations