Search in sources :

Example 1 with ModelNode

use of org.gradle.model.internal.core.ModelNode in project gradle by gradle.

the class ModelNodeRenderer method render.

@Override
public void render(ModelNode model, TextReportBuilder output) {
    if (model.isHidden() && !showHidden) {
        return;
    }
    StyledTextOutput styledTextoutput = output.getOutput();
    if (!model.getPath().equals(ModelPath.ROOT)) {
        printNodeName(model, styledTextoutput);
        maybePrintType(model, styledTextoutput);
        maybePrintValue(model, styledTextoutput);
        printCreator(model, styledTextoutput);
        maybePrintRules(model, styledTextoutput);
    }
    if (model instanceof ModelReferenceNode) {
        return;
    }
    Map<String, ModelNode> links = new TreeMap<String, ModelNode>();
    for (ModelNode node : model.getLinks(ModelType.untyped())) {
        links.put(node.getPath().getName(), node);
    }
    output.collection(links.values(), this);
}
Also used : ModelReferenceNode(org.gradle.model.internal.registry.ModelReferenceNode) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) TreeMap(java.util.TreeMap) ModelNode(org.gradle.model.internal.core.ModelNode)

Example 2 with ModelNode

use of org.gradle.model.internal.core.ModelNode in project gradle by gradle.

the class ModelReport method report.

@TaskAction
public void report() {
    Project project = getProject();
    StyledTextOutput textOutput = getTextOutputFactory().create(ModelReport.class);
    ModelNodeRenderer renderer = new ModelNodeRenderer(isShowHidden(), getFormat());
    TextModelReportRenderer textModelReportRenderer = new TextModelReportRenderer(renderer);
    textModelReportRenderer.setOutput(textOutput);
    textModelReportRenderer.startProject(project);
    ModelRegistry modelRegistry = getModelRegistry();
    ModelNode rootNode = modelRegistry.realizeNode(ModelPath.ROOT);
    // Ensure binding validation has been done. This should happen elsewhere
    modelRegistry.bindAllReferences();
    textModelReportRenderer.render(rootNode);
    textModelReportRenderer.completeProject(project);
    textModelReportRenderer.complete();
}
Also used : Project(org.gradle.api.Project) ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) ModelNodeRenderer(org.gradle.api.reporting.model.internal.ModelNodeRenderer) TextModelReportRenderer(org.gradle.api.reporting.model.internal.TextModelReportRenderer) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) ModelNode(org.gradle.model.internal.core.ModelNode) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

StyledTextOutput (org.gradle.internal.logging.text.StyledTextOutput)2 ModelNode (org.gradle.model.internal.core.ModelNode)2 TreeMap (java.util.TreeMap)1 Project (org.gradle.api.Project)1 ModelNodeRenderer (org.gradle.api.reporting.model.internal.ModelNodeRenderer)1 TextModelReportRenderer (org.gradle.api.reporting.model.internal.TextModelReportRenderer)1 TaskAction (org.gradle.api.tasks.TaskAction)1 ModelReferenceNode (org.gradle.model.internal.registry.ModelReferenceNode)1 ModelRegistry (org.gradle.model.internal.registry.ModelRegistry)1