Main Content

plot

Class: matlab.buildtool.Plan
Package: matlab.buildtool

Plot tasks in plan

Since R2022b

Description

example

plot(plan) plots the tasks in the plan as a dependency graph where nodes represent tasks and edges represent dependencies. Edges in the graph flow from dependent tasks to depended-on tasks.

The plot visualizes the plan as a directed acyclic graph. It cannot contain any cycles.

Input Arguments

expand all

Plan, specified as a matlab.buildtool.Plan object.

Examples

expand all

Plot the tasks in a build plan as a dependency graph.

Open the example and then navigate to the plot_plan_example folder, which contains a build file.

cd plot_plan_example

This code shows the contents of the build file.

function plan = buildfile
import matlab.buildtool.tasks.CodeIssuesTask
import matlab.buildtool.tasks.TestTask

% Create a plan from task functions
plan = buildplan(localfunctions);

% Add the "check" task to identify code issues
plan("check") = CodeIssuesTask;

% Add the "test" task to run tests
plan("test") = TestTask;

% Make the "archive" task the default task in the plan
plan.DefaultTasks = "archive";

% Make the "archive" task dependent on the "check" and "test" tasks
plan("archive").Dependencies = ["check" "test"];
end

function archiveTask(~)
% Create ZIP file
filename = "source_" + ...
    string(datetime("now",Format="yyyyMMdd'T'HHmmss"));
zip(filename,"*")
end

Load a plan from the build file.

plan = buildfile
plan = 
  Plan with tasks:

    archive - Create ZIP file
    check   - Identify code issues
    test    - Run tests

Plot the tasks in the plan as a dependency graph. The graph displays the tasks as nodes. Because the "archive" task depends on the "check" and "test" tasks, the graph also includes two edges that represent these dependencies.

plot(plan)

Version History

Introduced in R2022b